Skip to content

Commit

Permalink
Monkeypatch webmock's StubSocket due to a ruby 2.4.0 change in net/http
Browse files Browse the repository at this point in the history
Copied from: ManageIQ/manageiq#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.
  • Loading branch information
jrafanie committed Mar 24, 2017
1 parent 8dacc41 commit d16026e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/support/webmock_ruby24_bridge.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d16026e

Please sign in to comment.