我找不到我的问题的解决方案:cant login user in rspec test。
我尝试了这段代码,下面是这个链接 - https://github.com/plataformatec/devise/wiki/How-To:-Stub-authentication-in-controller-specs
require 'spec_helper'
require 'factory_girl_rails'
describe "ololo" do
it "blocks unauthenticated access" do
user = User.create(email: "lol@mail.com", password: "123456")
request.env['warden'].stub(:authenticate!).
and_throw(:warden, {:scope => :user})
visit "/tasks"
page.should have_content("Signed in successfully.")
end
end
/错误/
Failure/Error: page.should have_content("Signed in successfully.")
expected there to be text "Signed in successfully." in "Task App Home Login You need to sign in or sign up before continuing. Sign in Email Password Remember me Sign upForgot
你的密码?Denys Medynskyi 的任务应用程序”
也试过这个链接 - http://codingdaily.wordpress.com/2011/09/13/rails-devise-and-rspec/。
设计 wiki 教程也不适合我。
拜托,我几乎没有卡住。帮助我任何人。