Permalink
Browse files

Updated CHANGELOG and README with information about net_http_connect_…

…on_start option
  • Loading branch information...
bblimke committed Nov 2, 2010
1 parent 05da613 commit 4e313c29ac483746ef6c7ae5216b9a347029ca9a
Showing with 28 additions and 0 deletions.
  1. +8 −0 CHANGELOG.md
  2. +20 −0 README.md
View
@@ -15,6 +15,14 @@
* `rake spec NO_CONNECTION=true` can now be used to only run WebMock specs which do not make real network connections
+* `net_http_connect_on_start` option can be passed to `WebMock.allow_net_connect!` and `WebMock.disable_net_connect!` methods, i.e.
+
+ WebMock.allow_net_connect!(:net_http_connect_on_start => true)
+
+ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`. Look for 'Connecting on Net::HTTP.start' in README, for more information.
+
+ Thanks to Alastair Brunton for reporting the issue and fix suggestions.
+
## 1.4.0
* Curb support!!! Thanks to the awesome work of Pete Higgins!
View
@@ -310,6 +310,25 @@ You can also use WebMock outside a test framework:
Net::HTTP.get('www.example.org', '/') # ===> Allowed.
+## Connecting on Net::HTTP.start
+
+ HTTP protocol has 3 steps: connect, request and response (or 4 with close). Most Ruby HTTP client libraries
+ treat connect as a part of request step, with the exception of `Net::HTTP` which
+ allows opening connection to the server separately to the request, by using `Net::HTTP.start`.
+
+ WebMock API was also designed with connect being part of request step, and it only allows stubbing
+ requests, not connections. When `Net::HTTP.start` is called, WebMock doesn't know yet whether
+ a request is stubbed or not. WebMock by default delays a connection until the request is invoked,
+ so when there is no request, `Net::HTTP.start` doesn't do anything.
+ **This means that WebMock breaks the Net::HTTP behaviour by default!**
+
+ To workaround this issue, WebMock offers `net_http_connect_on_start` option,
+ which can be passed to `WebMock.allow_net_connect!` and `WebMock#disable_net_connect!` metods, i.e.
+
+ WebMock.allow_net_connect!(:net_http_connect_on_start => true)
+
+ This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
+
## Setting Expectations
### Setting expectations in Test::Unit
@@ -538,6 +557,7 @@ People who submitted patches and new features or suggested improvements. Many th
* Ryan Bigg
* Pete Higgins
* Hans de Graaff
+* Alastair Brunton
## Background

0 comments on commit 4e313c2

Please sign in to comment.