I am migrating my standart Rails unit tests to RSpec and i have problems with devise. All controller containing devise authentication are failing with RSpec.
I try to sign_in an admin in RSpec following the devise tutorial, without success :
Here is what i tried :
/spec/controllers/ipad_tech_infos_controller_spec.rb
before :each do
@request.env["devise.mapping"] = Devise.mappings[:admin]
@admin = FactoryGirl.create :admin
sign_in @admin
end
/spec/support/devise.rb
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
end
/spec/factories/admin.rb
FactoryGirl.define do
factory :admin do
email "abc@abc.com"
password "foobar"
password_confirmation {|u| u.password}
end
end
My model is not confirmable, all my controller spec are failing.
If i remove before_filter :authenticate_admin! then all my tests pass.
Can anybody help ?