Skip to content

Commit

Permalink
Consider 0.0.0.0 to be a localhost alias.
Browse files Browse the repository at this point in the history
Note that WebMock doesn't yet consider 0.0.0.0 to be localhost, so it doesn't fully work if you use WebMock.

Closes vcr#15.
  • Loading branch information
myronmarston committed Sep 28, 2010
1 parent a2bdbeb commit 6c86a96
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@
* Fixed VCR/Net::HTTP/WebMock integration so that VCR no longer loads its Net::HTTP monkey patch when
WebMock is used, and relies upon WebMock's after_request callback to record Net::HTTP instead. This
fixes [a bug](http://github.com/myronmarston/vcr/issues/14) when using WebMock and Open URI.
* Consider 0.0.0.0 to be a localhost alias (previously only "localhost" and 127.0.0.1 were considered).

## 1.1.2 (September 9, 2010)

Expand Down
2 changes: 1 addition & 1 deletion lib/vcr.rb
Expand Up @@ -14,7 +14,7 @@
module VCR
extend self

LOCALHOST_ALIASES = %w( localhost 127.0.0.1 )
LOCALHOST_ALIASES = %w( localhost 127.0.0.1 0.0.0.0 )

def current_cassette
cassettes.last
Expand Down
23 changes: 23 additions & 0 deletions spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml
Expand Up @@ -53,6 +53,29 @@
- "277"
:body: 127.0.0.1 response
:http_version: "1.1"
- !ruby/struct:VCR::HTTPInteraction
:request: !ruby/struct:VCR::Request
:method: :get
:uri: http://0.0.0.0:80/
:body:
:headers:
:response: !ruby/struct:VCR::Response
:status: !ruby/struct:VCR::ResponseStatus
:code: 404
:message: Not Found
:headers:
content-type:
- text/html; charset=iso-8859-1
connection:
- close
server:
- Apache/2.2.3 (CentOS)
date:
- Thu, 25 Feb 2010 07:53:52 GMT
content-length:
- "277"
:body: 127.0.0.1 response
:http_version: "1.1"
- !ruby/struct:VCR::HTTPInteraction
:request: !ruby/struct:VCR::Request
:method: :get
Expand Down
23 changes: 23 additions & 0 deletions spec/fixtures/not_1.9.1/cassette_spec/with_localhost_requests.yml
Expand Up @@ -53,6 +53,29 @@
- "277"
body: 127.0.0.1 response
http_version: "1.1"
- !ruby/struct:VCR::HTTPInteraction
request: !ruby/struct:VCR::Request
method: :get
uri: http://0.0.0.0:80/
body:
headers:
response: !ruby/struct:VCR::Response
status: !ruby/struct:VCR::ResponseStatus
code: 404
message: Not Found
headers:
content-type:
- text/html; charset=iso-8859-1
connection:
- close
server:
- Apache/2.2.3 (CentOS)
date:
- Thu, 25 Feb 2010 07:53:52 GMT
content-length:
- "277"
body: 127.0.0.1 response
http_version: "1.1"
- !ruby/struct:VCR::HTTPInteraction
request: !ruby/struct:VCR::Request
method: :get
Expand Down
1 change: 1 addition & 0 deletions spec/support/http_library_adapters.rb
Expand Up @@ -206,6 +206,7 @@ def test_request_stubbed(method, url, expected)
before(:each) { subject.ignore_localhost = true }

it "allows requests to #{localhost_alias}" do
pending "Waiting for WebMock to add 0.0.0.0 as a localhost alias as well" if localhost_alias == '0.0.0.0' && subject == VCR::HttpStubbingAdapters::WebMock
get_body_string(make_http_request(:get, "http://#{localhost_alias}:#{localhost_server.port}/")).should == localhost_response
end
end
Expand Down

0 comments on commit 6c86a96

Please sign in to comment.