I\'m trying to write a request test that asserts that the proper links appear on the application layout depending in whether a user is logged in or out. FWIW, I\'m using Dev
Just in case anyone else runs into this, for the same reason as me - I had the same problem on basically all my tests after a change to some config files - it turned out it was due to RAILS_ENV
being set to development
when I ran the tests by accident. Might be worth checking before adding a test-specific rails initializer :-)
For future readers: I received same error, but for a different reason.
Our app had multiple user models where one derived from the other
For arguments sake:
class SimpleUser
class User < SimpleUser
In my controller I used a reference to SimpleUser (the parent class), but Devise was configured to use User (the child class).
During an invocation of Devise::Mapping.find_scope! it does .is_a? comparison against the object reference and the configured class.
Since my reference was a SimpleUser, and the configured class was User, the .is_a? fails because the comparison was asking if the Parent class is_a? Child class, which is always false.
Hope that helps someone else.
i know this is an old thread, but i wanted an answer to whoever else runs into this. not sure where i read this, but props to the person who posted about this on another forum.
Long and the short is that the devise test helpers don't work well with integration tests.
So remove all references for Devise::TestHelpers (some people use include, other people use require 'devise/testhelpers') from within the specs themselves.
then in the spec_helper file add:
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
end