From 15fa32dd5f29d6906f69ff42ddb078423a248480 Mon Sep 17 00:00:00 2001 From: Tom Scott Date: Mon, 4 Jun 2018 14:35:05 -0400 Subject: [PATCH] Fix WebMock regression in 1.79.2 Since Webmock [overrides the Net::HTTP#start method](https://github.com/bblimke/webmock/blob/master/lib/webmock/http_lib_adapters/net_http.rb#L144) to simulate HTTP requests, unsafe usage of `@socket` in ActiveMerchant's `Net::HTTP#ssl_connection` refinement caused cryptic errors in tests that used VCR along with ActiveMerchant: ``` MyProject::TotallyFabulousIntegrationTest#test_fabulosity: NoMethodError: undefined method `io' for nil:NilClass test/test_helper.rb:44:in `use_cassette' .../gems/activemerchant-1.79.0/lib/active_merchant/net_http_ssl_connection.rb:6:in `ssl_connection' .../gems/activemerchant-1.79.0/lib/active_merchant/connection.rb:78:in `block (2 levels) in request' ... ``` --- lib/active_merchant/net_http_ssl_connection.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/active_merchant/net_http_ssl_connection.rb b/lib/active_merchant/net_http_ssl_connection.rb index ed359ae67e2..d0764cbc615 100644 --- a/lib/active_merchant/net_http_ssl_connection.rb +++ b/lib/active_merchant/net_http_ssl_connection.rb @@ -3,6 +3,7 @@ module NetHttpSslConnection refine Net::HTTP do def ssl_connection + return {} unless @socket.present? { version: @socket.io.ssl_version, cipher: @socket.io.cipher[0] } end end