Dev_ sign_in method throws NoMethodError in RSpec test

The devise sign_in method should take store: false

as a second parameter, which seems to do it fine if I haven't in RSpec

and used it Devise::TestHelpers

.

When I run this test from sessions_controller_spec.rb

:

require 'rails_helper'
describe Api::V1::SessionsController do
  before(:each) do
    @user = FactoryGirl.create :user
  end
  ...
  describe 'DELETE #destroy' do
    before(:each) do
      sign_in @user, store: false
      delete :destroy, id: @user.auth_token
    end
    it { should respond_with 204 }
  end
end

      

I am getting this failure: enter image description here

+3


source to share


1 answer


I have the same problem. According to the Devise site, there is no such method. Try to remove the "store: false" parameter and run it again. He solved my problem.

...
describe 'DELETE #destroy' do
before(:each) do
  sign_in @user
  delete :destroy, id: @user.auth_token
end
it { should respond_with 204 }
...

      

And don't forget to put the following inside a file named spec / support / devise.rb or in spec / spec_helper.rb (or spec / rails_helper.rb if you are using rspec-rails



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

      

Take a look at this link

+1


source







All Articles