eliotsykes / rspec-rails-examples

RSpec cheatsheet & Rails app: Learn how to expertly test Rails apps from a model codebase
MIT License
2.16k stars 319 forks source link

Example of puffing-billy + VCR concurrent usage in same feature spec (Stripe checkout.js?) #99

Open eliotsykes opened 8 years ago

eliotsykes commented 8 years ago

Provide example spec for testing Stripe's checkout.js whilst also communicating with the Stripe API.

Include:

  ...

  within_frame 'stripe_checkout_app' do
    fill_in 'Email', with: 'a@b.c'
    fill_in_stripe_field '#card_number', with: '4242424242424242'
    fill_in_stripe_field '#cc-exp', with: '12/22'
    fill_in 'CVC', with: '123'
    click_button 'Upgrade $9.99'
  end

  ...

  def fill_in_with_force(locator, options)
    page.execute_script "$('#{locator}').val('#{options[:with]}');"
  end

  alias_method :fill_in_stripe_field, :fill_in_with_force

  ...
eliotsykes commented 8 years ago

Once up and running reply to this SO Q to help: https://stackoverflow.com/questions/29861371/how-can-i-test-stripe-js-using-poltergeist-and-capybara

eliotsykes commented 8 years ago

This will demo usage of c.ignore_params = [...] for Stripe's cache-busting URLs.

Also demo how to config to ignore unwanted 3rd party requests e.g. Mixpanel in test environment seems to be included by Stripe.

eliotsykes commented 8 years ago

Puffing Billy, JSONP and Stripe may be relevant: https://github.com/oesmith/puffing-billy/issues/55

eliotsykes commented 8 years ago

WIP #101