我已经使用水豚一段时间了,但我是巫术新手。我有一个非常奇怪的问题,如果我在没有 Capybara 的 :js => true 功能的情况下运行规范,我可以正常登录,但是如果我尝试在规范上指定 :js => true ,则找不到用户名/密码。
这是身份验证宏:
module AuthenticationMacros
def sign_in
user = FactoryGirl.create(:user)
user.activate!
visit new_sessions_path
fill_in 'Email Address', :with => user.email
fill_in 'Password', :with => 'foobar'
click_button 'Sign In'
user
end
end
在这样的规格中调用:
feature "project setup" do
include AuthenticationMacros
background do
sign_in
end
scenario "creating a project" do
"my spec here"
end
上面的代码工作正常。但是,如果我从(在这种情况下)更改场景规范
scenario "adding questions to a project" do
到
scenario "adding questions to a project", :js => true do
登录失败并出现“不正确的用户名/密码”组合。从字面上看,唯一的变化是 :js => true。我正在使用默认的 capybara javascript 驱动程序。(加载 Firefox)
Any ideas what could be going on here? I'm completely stumped. I'm using Capybara 2.0.1, Sorcery 0.7.13. There is no javascript on the sign in page and save_and_open_page before clicking 'sign in' confirms that the correct details are entered into the username/password fields. Any suggestions really appreciated - I'm at a loss.