Pages

Tuesday, September 20, 2011

How to include devise test helpers in your rails 3 controller specs (rspec2)
including devise test helpers in your controllers would mean that you could use devise's helpers to sign_in, confirm! and so forth. For more info on the test helpers in devise, look in the devise documentation page.

Two ways:

1) put the following contents in a file, spec/support/devise.rb

RSpec.configure do |config|
 config.include Devise::TestHelpers, :type => :controller
end


2) put them in spec/spec_helper.rb

RSpec.configure do |config|
 config.include Devise::TestHelpers, :type => :controller
 config.extend ControllerMacros, :type => :controller # I'm using factory girl here
 config.use_transactional_fixtures = true
end