testing stripe checkout with cucumber and WebMock/VCR in my Rails app(fails without connection to the internet)

517 views Asked by At

Cucumber step that fails. When there is no internet connection. It can't download stripe checkout https://stripe.com/docs/checkout but how to fix or stub it I don't know :( Sorry if the question is not very clear, my english is sucks.

Test where I use 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

Code from view file, where checkout.js is connected. And this button don't appear without connection to the internet.

  <% 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 %>
0

There are 0 answers