I have a message controller and I just installed Devise to quickly and easily add authentication. Before I installed Devise, I created some tests for the "new" action of my message controller. After installing Devise, my tests failed until I added
config.include Devise::TestHelpers, :type => :controller
to my spec_helper.rb file.
I also have a string
before_filter :authenticate_user!, :except => [:show, :index]
in my mail dispatcher.
Now, when I run my tests, they all pass, with the exception of these 2:
it "should be successful" do get :new response.should be_success end it "should have the right title" do get :new response.should have_selector('title', :content => @base_title + " | New post") end
I am using a Factory girl. The error is caused by the before_filter except parameter. I need the user to be able to log into rspec with the Factory user. How can I sign a Factory user from an RSpec controller test? How to identify Factory user?
I tried this in my .rb factories:
Factory.define :user do |user| user.name "Test User" user.email "user@example.com" user.password "password" user.password_confirmation "password" end
But then I get the error:
NoMethodError: undefined method `password_salt=' for #<User:0x00000103cac958>
Any help would be greatly appreciated. Thanks.
controller rspec devise factory-bot
Jack
source share