有没有可以替代 Capybara 的替代品save_and_open_page
?我编写了一个测试用户注册表单的请求规范。成功注册后,这个测试应该产生,这个测试应该通过,但事实并非如此。
然而,当我最后这样做save_and_open_page
时,所有表单字段都是空白的。我可以在开发环境中反映这一点,自己进行数据输入,一切都通过了,所以我很难理解出了什么问题。我不能放弃这个,因为显然这是一个关键的测试。
我只做了一段时间的 TDD,所以关于这个堆栈(Capybara 和 Poltergeist)的任何提示或技巧都会有所帮助。我在使用相同堆栈的其他请求规范中没有类似的困难。
这是请求规范:
it 'allows a user to subscribe', js: true do
visit root_url
click_link "Pricing"
click_button "Subscribe", match: :first
fill_in "First name", with: "Marky"
fill_in "Last name", with: "Mark"
fill_in "Company", with: "The Funky Bunch"
fill_in "subscription_email", with: "marky.mark@thefunkybunch.com"
fill_in "Password", with: "MyString"
fill_in "Password confirmation", with: "MyString"
fill_in "Credit Card Number", with: "4242424242424242"
fill_in "Security Code on Card (CVV)", with: "123"
select "July", from: "Card Expiration"
select "2014", from: "card_year"
check "chkACCEPT"
click_button "Subscribe to myapp"
# The line below fails, but a save_and_open page just shows a blank form
current_path.should_not eq(new_subscription_path)
page.should have_content("Thank You")
end