ruby-on-railsstripe-paymentsrspec-railstls1.2poltergeist

Rails rspec feature tests are failing using 'stripe-ruby-mock' gem


In development environment, I'm able to test stripe payment(using test card).But running rspec feature test, the payment fails and I'm getting the following error.

Support for test mode requests made with versions of TLS lower than 1.2 has been disabled, and support in live mode will be dropped on June 13, 2018. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.

I'm using capybara(v2.13) along with poltergeist for feature tests. I tried the upgrading steps mentioned in this URL. But still the issue persists.


Solution

  • Since it's not clear from your question this answer assumes the error is occurring when the "browser" (PhantomJS used by Poltergeist) is making requests to Stripe. If the error is occurring for the server making requests to Stripe this answer will not make any difference.

    PhantomJS (which Poltergeist uses) has a '--ssl-protocol' command line option which Poltergeist defaults to TLSv1. You can customize that in your driver registration - https://github.com/teampoltergeist/poltergeist#customization.

    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, 
       phantomjs_options: ['--ssl-protocol=TLSv1.2']
      )
    end