Skip to content

Commit

Permalink
Merge branch 'update-net-http-mocks-for-ruby-2.3'
Browse files Browse the repository at this point in the history
* update-net-http-mocks-for-ruby-2.3:
  Add explanatory comment to test helper
  net/http uses connect_nonblock since 2.3.0

Thanks to @zeha for patching this in #56, and also to @davidcornu for
the version in #58.

This gets us all green on MRI Ruby 2.3 and below.

Closes #56.
References #57.
  • Loading branch information
chrisk committed Jun 23, 2017
2 parents cf8a475 + 7d72dd3 commit eab4632
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,16 @@ def setup_expectations_for_real_request(options = {})
OpenSSL::SSL::SSLSocket.expects(:===).with(socket).returns(true).at_least_once
OpenSSL::SSL::SSLSocket.expects(:new).with(socket, instance_of(OpenSSL::SSL::SSLContext)).returns(socket).at_least_once
socket.stubs(:sync_close=).returns(true)
socket.expects(:connect).with().at_least_once

# MRI's Net::HTTP switched from stdlib's timeout.rb to an internal
# implementation using io/wait and connect_nonblock in Ruby 2.3.
# See https://github.com/ruby/ruby/commit/bab5bf0c79ba
if RUBY_VERSION >= "2.3.0"
socket.expects(:connect_nonblock).with(any_parameters).at_least_once
else
socket.expects(:connect).with().at_least_once
end

if RUBY_VERSION >= "2.0.0" && RUBY_PLATFORM != "java"
socket.expects(:session).with().at_least_once
end
Expand Down

0 comments on commit eab4632

Please sign in to comment.