我正在使用水豚与恶作剧者在轨道上的红宝石中进行rspec测试 .
我们正在使用条带支付网关 .
请求条带已经存根并且实际的http连接被禁用 .
但是,当我单独运行spec文件时 .
它通过以下测试结果 .
可以向我的帐户添加结算信息
完成时间为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,但是我收到了这些错误 .
奇怪的是,如果我单独运行spec文件或查看规范的功能文件夹,那么我没有得到任何错误消息并且测试通过 . 但是如果我运行
rspec spec /然后测试失败 .
有人可以帮忙吗?
1 回答
看起来错误在你的截图中解释了 - 虽然localhost和127.0.0.1指向同一个地方,但它们在技术上是不同的起源 . 您需要找到设置应用程序的位置以向http://localhost/发出请求...并将其更改为127.0.0.1