Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change stub socket for Ruby 2.4 compat
Background: 1. As of Ruby 2.2, calling #close on a socket that's already closed no longer raises an exception. 2. As of Ruby 2.4, Net::HTTP no longer checks #closed? every time before calling #close on a socket, since there's no longer any danger it will raise. See: * r56795 (ruby/ruby@6394b63db9abe34234e7) * r56865 (ruby/ruby@f845a9ef76c0195254de) FakeWeb's internal StubSocket has been short-circuiting those pre-2.4 checks by just always returning true when #closed? is checked, preventing #close from ever being called. Now that the checks are gone, StubSocket needs its own #close method. This fixes a variety of NoMethodErrors on Ruby 2.4, but is basically backwards-compatible with earlier implementations. (When running on pre-Ruby 2.2, I suppose StubSocket should raise when you call #close on an already-closed socket. I'll look into that, but all our functional tests are passing on earlier Rubies at the moment.) While we're at it, I changed #closed? to stop just always returning true, to be closer to how the Ruby stdlib's sockets behave. This doesn't appear to break anything but I'll revert that part if I find anything in the relevant Net::HTTP code that conflicts. Thanks for reporting and submitting patches: @voxik in #59, @SamMolokanov in #60.
- Loading branch information