【发布时间】:2016-05-03 13:22:07
【问题描述】:
我正在使用 capybara 和 poltergeist 在 ruby on rails 中进行 rspec 测试。
我们正在使用条带作为支付网关。
在已存根中的条带化请求和真正的 http 连接被禁用。
但是当我单独运行规范文件时。
它通过了以下测试结果。
可以将帐单信息添加到我的帐户
在 14.27 秒内完成(文件加载需要 4.84 秒) 1 个示例,0 次失败
但是当我运行所有测试时,由于响应时间延迟很长,它失败了,我得到了这个输出。
失败:
我的代码-
scenario "Can add billing information to my account", js: true do
within "#top-menu" do
click_link "ACCOUNT"
end
click_link "Billing"
click_link "Add billing information"
within "#subscription" do
fill_in "Name", with: "John Smith"
fill_in "Email", with: "john.smith@example.com"
fill_in "Phone number", with: "0443 123123"
fill_in "Company", with: "Cribber"
fill_in "Street address", with: "14 Somewhere Street"
fill_in "City", with: "Brisbane"
fill_in "Postcode / Zip", with: "4000"
fill_in "State", with: "QLD"
select "Australia", from: "Country"
select "Australian Dollar", from: "Currency"
fill_in "Card number", with: "4242424242424242"
select Time.now.year + 1, from: "card_expiry_year"
fill_in "CVC", with: "123"
check "subscription_billing_attributes_terms_of_service"
end
click_button "Subscribe"
expect(page).to have_content("Thank you for subscribing to Cribber!")
end
我在click_button“订阅”之后添加了sleep(200)。但它显示了以下结果。
有人可以帮忙吗?
提前感谢您的帮助。
我尝试在 .env.test 文件中将 http://localhost 更改为 http://127.0.0.1,但出现这些错误。
奇怪的是,如果我单独运行规范文件或查看规范的功能文件夹,那么我不会收到错误消息并且测试通过。但是如果我运行
rspec spec/ 则测试失败。
谁能帮忙?
【问题讨论】:
标签: ruby-on-rails rspec capybara rspec-rails poltergeist