How to use HTTP status code symbols in RSpec?

The response object responds to several of the symbol types as messages. So you can simply do: expect(response).to be_success expect(response).to be_error expect(response).to be_missing expect(response).to be_redirect For the other types, such as :created, you can create a simple custom matcher for this which wraps assert_response: RSpec::Matchers.define :have_status do |type, message = nil| match do |_response| assert_response … Read more

Testing (RSpec) with Devise’s confirmable module

In your test environment ActionMailer::Base.delivery_method should be set to :test, which means that these emails will not be sent out. If this setting is set to something else such as smtp by way of a configuration in say config/environments.rb, then emails will be sent out. If that setting’s already there, then to use the User … Read more

FactoryGirl screws up rake db:migrate process

I think you need to have factory girl definition like that in Gemfile: gem ‘factory_girl_rails’, :require => false And then you just require it in your spec_helper.rb like that: require ‘factory_girl_rails’ This is the way I’m always using this gem. You don’t need to require it in other places than spec_helper.rb. Your current desired approach … Read more

Pass parameter in setting attribute on association in FactoryGirl

The association helper in factory_girl can’t take dynamic property arguments, but you can use a dynamic attribute to instantiate the association however you want: factory :tx_link do units “9.99” factory :link_red_to_sub do transient do sub 0 red 0 end units { red } giver { create(:transaction, units: sub) } taker { create(:redemption, units: red) } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)