Permalink
Browse files

Consider 0.0.0.0 to be a localhost alias.

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 #15.
  • Loading branch information...
1 parent a2bdbeb commit 6c86a96a835ac9054ec3dd943d6c476591cdc9a7 @myronmarston committed Sep 28, 2010
View
1 CHANGELOG.md
@@ -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)
View
2 lib/vcr.rb
@@ -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
View
23 spec/fixtures/1.9.1/cassette_spec/with_localhost_requests.yml
@@ -56,6 +56,29 @@
- !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
:uri: http://example.com:80/
:body:
:headers:
View
23 spec/fixtures/not_1.9.1/cassette_spec/with_localhost_requests.yml
@@ -56,6 +56,29 @@
- !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
uri: http://example.com:80/
body:
headers:
View
1 spec/support/http_library_adapters.rb
@@ -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

0 comments on commit 6c86a96

Please sign in to comment.