sign_in user如果设计不适用于rspec

时间:2017-05-21 03:08:10

标签: ruby ruby-on-rails-4 rspec devise rspec-rails

关注this

我想出了这段代码:

config.include FactoryGirl::Syntax::Methods
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Controllers::UrlHelpers
config.include Warden::Test::Helpers

并在控制器规范中:

before(:each) do
 sign_in user
 get :index
end

it "should have a current_user" do
 expect(subject.current_user).to_not eq(nil)
end

subject.current_user即将成为零。我想知道为什么会这样。

0 个答案:

没有答案