Permalink
Browse files

Added explanatory note about VCR to FakeWeb::NetConnectNotAllowedErro…

…r#message.
  • Loading branch information...
1 parent e0993a2 commit b7a3f4bbbc67d6bd4e697c9d18f3ba918f0b8098 @myronmarston committed Mar 4, 2010
@@ -43,7 +43,7 @@ Feature: Record response
Scenario: Make an HTTP request in a cassette with record mode set to :none
Given we do not have a "temp/record_none_cassette" cassette
When I make an HTTP get request to "http://example.com" within the "temp/record_none_cassette" none cassette
- Then the HTTP get request to "http://example.com" should result in a fakeweb error
+ Then the HTTP get request to "http://example.com" should result in a fakeweb error that mentions VCR
And there should not be a "temp/record_none_cassette" cache file
@copy_not_the_real_response_to_temp
@@ -42,7 +42,7 @@ Feature: Replay recorded response
And we have a "temp/not_the_real_response" file with no previously recorded response for "http://example.com/foo"
When I make HTTP get requests to "http://example.com" and "http://example.com/foo" within the "temp/not_the_real_response" none cassette
Then the response for "http://example.com" should match /This is not the real response from example\.com/
- And the HTTP get request to "http://example.com/foo" should result in a fakeweb error
+ And the HTTP get request to "http://example.com/foo" should result in a fakeweb error that mentions VCR
@copy_not_the_real_response_to_temp
Scenario: Make an HTTP request in a cassette with record mode set to :unregistered
@@ -92,8 +92,10 @@ def recorded_responses_for(cassette_name)
# do nothing...
end
-Then /^the HTTP get request to "([^\"]*)" should result in a fakeweb error$/ do |url|
- @http_requests[url][0].should be_instance_of(FakeWeb::NetConnectNotAllowedError)
+Then /^the HTTP get request to "([^\"]*)" should result in a fakeweb error that mentions VCR$/ do |url|
+ result = @http_requests[url][0]
+ result.should be_instance_of(FakeWeb::NetConnectNotAllowedError)
+ result.message.should =~ /VCR/
end
Then /^(?:the )?response(?: (\d+))? for "([^\"]*)" should match \/(.+)\/$/ do |response_num, url, regex_str|
@@ -15,4 +15,10 @@ def remove(method, url)
end
end
end
+
+ class NetConnectNotAllowedError
+ def message
+ super + '. You can use VCR to automatically record this request and replay it later with fakeweb. For more details, see the VCR README at: http://github.com/myronmarston/vcr'
+ end
+ end
end
@@ -23,4 +23,11 @@
@remove_example_dot_com.should_not change { FakeWeb.registered_uri?(:get, 'http://google.com') }
end
end
+
+ describe 'FakeWeb::NetConnectNotAllowedError#message' do
+ it 'includes a note about VCR' do
+ FakeWeb::NetConnectNotAllowedError.new('The fakeweb error message').message.should ==
+ 'The fakeweb error message. You can use VCR to automatically record this request and replay it later with fakeweb. For more details, see the VCR README at: http://github.com/myronmarston/vcr'
+ end
+ end
end

0 comments on commit b7a3f4b

Please sign in to comment.