Skip to content

Instantly share code, notes, and snippets.

View JanDintel's full-sized avatar

JanDintel

View GitHub Profile
@JanDintel
JanDintel / devise.nl.yml
Last active December 16, 2015 11:08
Dutch translation for Devise. Nederlandse vertaling voor Devise.
# Meer vetalingen via https://github.com/plataformatec/devise/wiki/I18n
# Voeg 'config.i18n.default_locale = :nl' toe in je 'application.rb' en herstart je server
nl:
devise:
confirmations:
confirmed: "Je account is bevestigd, je bent nu ingelogd."
send_instructions: "Je zult een e-mail met instructies ontvangen over hoe je jouw account moet bevestigen over een paar minuten."
send_paranoid_instructions: "Als je e-mail bestaat in onze database, zul je een e-mail met instructies ontvangen over hoe je jouw account moet bevestigen over een paar minuten."
failure:
@JanDintel
JanDintel / defaultglobal.gitignore
Created July 18, 2013 14:19
My default ROR on OS X gitignore
# Rails
*.rbc
*.sassc
.sass-cache
capybara-*.html
.rspec
.rvmrc
/.bundle
/vendor/bundle
/log/*
@JanDintel
JanDintel / .gitconfig
Created July 23, 2013 11:27
Global gitconfig ~/.gitconfig
[alias]
co = checkout
st = status
br = branch
com = commit
pl = pull
ps = push
@JanDintel
JanDintel / install.md
Last active December 20, 2015 04:29
Install Cucumber with Rspec, Guard (and livereload) and Spork

Install Cucumber with Rspec, Guard and Spork

Using during Hartl rails 4.0 guide (http://ruby.railstutorial.org/chapters)

Gems

group :development, :test
  gem 'guard-rspec'
  gem 'guard-livereload'
  gem 'spork-rails', github: 'sporkrb/spork-rails' # RubyGems.org nog uptodate
  gem 'guard-spork'

gem 'childprocess'

@JanDintel
JanDintel / install.md
Last active July 20, 2016 10:57
Install guide for Rspec, Guard, Spork, Cucumber and Mongoid

Install Cucumber with Rspec, Guard, Factory Girl(?) and Spork

Using during Hartl rails 4.0 guide (http://ruby.railstutorial.org/chapters)

Gems

group :development, :test
  gem 'guard-rspec'
  gem 'guard-livereload'
  gem 'spork-rails', github: 'sporkrb/spork-rails' # rubygems version not rails 4 compatible
  gem 'guard-spork'
@JanDintel
JanDintel / Factory Girl and Cucumber.md
Created July 25, 2013 09:13
Factory Girl and Cucumber testing

Factory Girl and Cucumber

Use the outside to inside method. Your features should be abstract and using Factory Girl step definitions forces you to know specific details about the implementation of your application. See: http://robots.thoughtbot.com/post/25650434584/writing-better-cucumber-scenarios-or-why-were So keep in mind, you're testing the logic of the models (methodes, validations..) and controllers with Rspec and the views and 'behavior' of the end user with Cucumber. For some of those best practices, see: http://blog.codeship.io/2013/05/21/testing-tuesday-6-top-5-cucumber-best-practices.html

@JanDintel
JanDintel / readme.md
Last active December 20, 2015 05:38
Use Factory Girl for user helper in Cucumber

Using Factory Girl with a helper for Cucumber

Using Factory Girl directly in your steps

(./features/step_definitions/function_name_steps.rb)

Given /^the user has an account$/ do
    @user = FactoryGirl.create(:user)
end
@JanDintel
JanDintel / gist:6088237
Last active August 27, 2021 21:35
Using RSpec with Rails 4 PATCH method

Using Rspec with Rails 4 patch method

In Rails 4 PATCH is the new HTTP methode for an update action. You can find the details here: http://weblog.rubyonrails.org/2012/2/25/edge-rails-patch-is-the-new-primary-http-method-for-updates/

Using PATCH in your specs

As you can imagine you need to use the PATCH method to test the update action in your controller. Because of how the users controller in this example works you need to specify the id and user. This particular spec tests whether the user gets redirected if it's not logged in.

(./spec/controllers/users_controller_spec.rb)

require 'spec_helper'
@JanDintel
JanDintel / Git aliases
Last active December 23, 2015 04:59 — forked from JobV/Git aliases
git config --global alias.co checkout
git config --global alias.st status
git config --global alias.br branch
git config --global alias.com commit
git config --global alias.pl pull
git config --global alias.ps push
@JanDintel
JanDintel / infrastructure_controller.rb
Last active December 23, 2015 06:39
InfrastructureController to support Nagios health check
# app/controllers/infrastructure_controller.rb
class InfrastructureController < ActionController::Base
def health_check
@checks = { database: ActiveRecord::Migrator.current_version,
redis: redis_check,
version: %x(git log --pretty=format:'%h' -1) }
if @checks[:redis] == "Not connected"
@notification = "Error 500, Can't find Redis"