关注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
即将成为零。我想知道为什么会这样。