From d16026e212678750f4215dcbd8789e7cb9ddd5c3 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Fri, 24 Mar 2017 13:54:15 -0400 Subject: [PATCH] Monkeypatch webmock's StubSocket due to a ruby 2.4.0 change in net/http Copied from: https://github.com/ManageIQ/manageiq/pull/13104 Ruby 2.4.0 removed the closed? check in the conditional in: s.close if !s.closed? Webmock was changed to add close to StubSocket along with another change.. ruby/ruby@f845a9e bblimke/webmock@8f2176a WebMock 2.3.1+ fixed the issue with ruby 2.4.0 by adding StubSocket#close. --- spec/support/webmock_ruby24_bridge.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 spec/support/webmock_ruby24_bridge.rb diff --git a/spec/support/webmock_ruby24_bridge.rb b/spec/support/webmock_ruby24_bridge.rb new file mode 100644 index 000000000..f266ed798 --- /dev/null +++ b/spec/support/webmock_ruby24_bridge.rb @@ -0,0 +1,16 @@ +# Ruby 2.4.0 removed the closed? check in the conditional in: s.close if !s.closed? +# Webmock was changed to add close to StubSocket along with another change. +# https://github.com/ruby/ruby/commit/f845a9ef76c0195254ded79c85c24332534f4057 +# https://github.com/bblimke/webmock/commit/8f2176a1fa75374df55b87d782e08ded673a75b4 +# WebMock 2.3.1+ fixed this. +# We should upgrade webmock but that requires some re-recording of cassettes (I think) +# and maybe other things. +require 'webmock' +if WebMock::VERSION < "2.3.1" + class StubSocket + def close + end + end +else + warn "Remove me: #{__FILE__}:#{__LINE__}. WebMock 2.3.1+ fixed the issue with ruby 2.4.0 by adding StubSocket#close." +end