1

失败的黄瓜步骤。当没有互联网连接时。它无法下载条带结帐https://stripe.com/docs/checkout但如何修复或存根我不知道 :( 抱歉,如果问题不是很清楚,我的英语很烂。

测试我在哪里使用 VCR

Then(/^I get to purchases Clarity$/) do
  VCR.use_cassette("stripe_clarity_payment", :record => :new_episodes) do
    expect(page).to have_content '$45 once off payment'
    expect(page).to have_xpath("//img[@src=\"/assets/clarity_icon.png\"]")
    sleep 0.5
    click_on 'Purchase'
    stripe_iframe = all('iframe[name=stripe_checkout_app]').last
    within_frame stripe_iframe do
      page.execute_script(%Q{ $('input#card_number').val('4242424242424242'); })
      page.execute_script(%Q{ $('input#cc-exp').val('12/15'); })
      page.execute_script(%Q{ $('input#cc-csc').val('111'); })
      click_on 'Pay $45.00'
      sleep 1
    end
  end
end

视图文件中的代码,其中 checkout.js 已连接。如果没有连接到互联网,此按钮不会出现。

  <% if user_signed_in? %>
      <script src="https://checkout.stripe.com/checkout.js"></script>
      <%= form_tag orders_path, :class => "form-container" do %>
          <p><%= link_to "Purchase", "#", :id => "purchase-coaching", :class => "btn btn-lg btn-success", :html => {:role => "button"} %></p>
      <% end %>
  <% else %>
      <p><%= link_to "Log in to purchase", new_user_session_path, :class => "btn btn-lg btn-success", :html => {:role => "button"} %></p>
  <% end %>
4

0 回答 0