【发布时间】:2015-04-25 00:39:21
【问题描述】:
测试条带框架需要打开 Javascript,但是当我在 it 方法中发送 js: true 时,其他组件如 visit、fill_in 将停止以之前的方式工作。
这是我的代码:
def sign_up(subdomain)
visit root_url(subdomain: false)
visit new_account_path
fill_in 'Name', with: 'Ryan'
fill_in 'Email', with: 'test@test.com'
fill_in 'Password', with: 'password'
fill_in 'Password confirmation', with: 'password'
fill_in 'Subdomain', with: subdomain
click_button 'Create Account'
end
在sign_up 方法中,visit new_account_path 在js: true 之前可以工作,但现在不行了。
我正在转js: true,方法如下:
it 'shows the user can upgrade his account with valid card number, expiration and CVC', js: true do
fill_in "card_number", :with => "4242424242424242"
fill_in "card_expiry_month", :with => "05"
fill_in "card_expiry_year", :with => "2015"
fill_in "card_cvc", :with => "123"
click_button 'Upgrade Your Account'
expect(page).to have_content "Update Your Payment Information"
end
我一直在寻找解决方案很长一段时间,但到目前为止无法解决这个问题。
【问题讨论】:
-
那条线上到底是什么失败了?您是否收到错误消息或其他信息?
-
Failure/Error: click_button 'Upgrade Your Account' Stripe::InvalidRequestError:这是我得到的错误。 -
好的,stripe 需要知道允许的 url 列表吗?测试期间使用的 url 是这些允许的 url 之一吗?
-
我不知道你在问什么:但是有什么方法可以在不执行
js: true的情况下测试stripe。因为当我做js: true时,它会导致问题:它不允许我fill_in一些我在问题中描述的元素。
标签: ruby-on-rails testing rspec stripe-payments