Devise. A Blessing and an absolute curse for noobs. Sure, logins and logouts made easy, but customizing devise to suit your needs can be a little bit daunting for a noobie. Below is the list of stuff I’ve run into over the years.
These are the problems and potential solutions, but a little bit of knowledge can go a LONG way. Devise offers customization. This customization usually happens when rails is loaded. That means the customization typically needs to happen in initializers. Those are kept in
test/test_helper.rb. Those first two files will not come automatically for you, you’ll have to create them.
Testing Controllers with a User
Add this line of code to
spec/support/devise.rb when receiving
undefined methodauthenticate’ for nil:NilClass`
RSpec.configure do |config| config.include Devise::TestHelpers, type: :controller end
Then your test should start passing.
See this StackOverflow post for more information