vcr 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/CHANGELOG.md +11 -1
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +4 -3
  4. data/benchmarks/http_stubbing_libraries.rb +4 -4
  5. data/features/.nav +1 -0
  6. data/features/configuration/ignore_hosts.feature +61 -0
  7. data/features/http_libraries/net_http.feature +34 -0
  8. data/features/step_definitions/cli_steps.rb +16 -1
  9. data/lib/vcr.rb +23 -14
  10. data/lib/vcr/cassette.rb +2 -4
  11. data/lib/vcr/config.rb +20 -5
  12. data/lib/vcr/deprecations.rb +27 -14
  13. data/lib/vcr/http_stubbing_adapters/fakeweb.rb +14 -9
  14. data/lib/vcr/http_stubbing_adapters/faraday.rb +12 -3
  15. data/lib/vcr/http_stubbing_adapters/typhoeus.rb +3 -7
  16. data/lib/vcr/http_stubbing_adapters/webmock.rb +17 -7
  17. data/lib/vcr/middleware/faraday.rb +1 -1
  18. data/lib/vcr/request_matcher.rb +12 -8
  19. data/lib/vcr/structs/http_interaction.rb +16 -0
  20. data/lib/vcr/structs/normalizers/body.rb +24 -0
  21. data/lib/vcr/structs/normalizers/header.rb +56 -0
  22. data/lib/vcr/structs/normalizers/status_message.rb +17 -0
  23. data/lib/vcr/structs/normalizers/uri.rb +34 -0
  24. data/lib/vcr/structs/request.rb +20 -0
  25. data/lib/vcr/structs/response.rb +16 -0
  26. data/lib/vcr/structs/response_status.rb +9 -0
  27. data/lib/vcr/util/regexes.rb +37 -0
  28. data/lib/vcr/version.rb +16 -5
  29. data/spec/spec_helper.rb +26 -3
  30. data/spec/support/http_library_adapters.rb +11 -12
  31. data/spec/support/http_stubbing_adapter.rb +2 -16
  32. data/spec/support/normalizers.rb +84 -0
  33. data/spec/support/version_checker.rb +1 -1
  34. data/spec/vcr/cassette_spec.rb +8 -10
  35. data/spec/vcr/config_spec.rb +63 -17
  36. data/spec/vcr/deprecations_spec.rb +83 -24
  37. data/spec/vcr/http_stubbing_adapters/multi_object_proxy_spec.rb +1 -1
  38. data/spec/vcr/http_stubbing_adapters/typhoeus_spec.rb +2 -2
  39. data/spec/vcr/middleware/faraday_spec.rb +1 -1
  40. data/spec/vcr/structs/http_interaction_spec.rb +23 -0
  41. data/spec/vcr/structs/request_spec.rb +54 -0
  42. data/spec/vcr/structs/response_spec.rb +39 -0
  43. data/spec/vcr/structs/response_status_spec.rb +18 -0
  44. data/spec/vcr_spec.rb +26 -54
  45. data/vcr.gemspec +1 -1
  46. metadata +48 -31
  47. data/TODO.md +0 -5
  48. data/lib/vcr/structs.rb +0 -176
  49. data/spec/vcr/structs_spec.rb +0 -201
@@ -340,7 +340,7 @@ module HttpLibrarySpecs
340
340
  end
341
341
 
342
342
  [true, false].each do |http_allowed|
343
- context "when #http_connections_allowed is set to #{http_allowed}" do
343
+ context "when http_connections_allowed is set to #{http_allowed}" do
344
344
  before(:each) { subject.http_connections_allowed = http_allowed }
345
345
 
346
346
  it "returns #{http_allowed} for #http_connections_allowed?" do
@@ -350,25 +350,24 @@ module HttpLibrarySpecs
350
350
  test_real_http_request(http_allowed, *other)
351
351
 
352
352
  unless http_allowed
353
- describe '.ignore_localhost =' do
354
- localhost_response = "Localhost response"
353
+ localhost_response = "Localhost response"
354
+
355
+ describe '.ignore_hosts' do
355
356
  let(:record_mode) { :none }
356
357
 
357
- VCR::LOCALHOST_ALIASES.each do |localhost_alias|
358
- describe 'when set to true' do
359
- before(:each) { subject.ignore_localhost = true }
358
+ context 'when set to ["127.0.0.1", "localhost"]' do
359
+ before(:each) do
360
+ subject.ignored_hosts = ["127.0.0.1", "localhost"]
361
+ end
360
362
 
363
+ %w[ 127.0.0.1 localhost ].each do |localhost_alias|
361
364
  it "allows requests to #{localhost_alias}" do
362
365
  get_body_string(make_http_request(:get, "http://#{localhost_alias}:#{VCR::SinatraApp.port}/localhost_test")).should == localhost_response
363
366
  end
364
367
  end
365
368
 
366
- describe 'when set to false' do
367
- before(:each) { subject.ignore_localhost = false }
368
-
369
- it "does not allow requests to #{localhost_alias}" do
370
- expect { make_http_request(:get, "http://#{localhost_alias}:#{VCR::SinatraApp.port}/localhost_test") }.to raise_error(NET_CONNECT_NOT_ALLOWED_ERROR)
371
- end
369
+ it 'does not allow requests to 0.0.0.0' do
370
+ expect { make_http_request(:get, "http://0.0.0.0:#{VCR::SinatraApp.port}/localhost_test") }.to raise_error(NET_CONNECT_NOT_ALLOWED_ERROR)
372
371
  end
373
372
  end
374
373
  end
@@ -3,20 +3,6 @@ shared_examples_for "an http stubbing adapter" do |supported_http_libraries, sup
3
3
  before(:each) { VCR.stub!(:http_stubbing_adapter).and_return(subject) }
4
4
  subject { described_class }
5
5
 
6
- describe '.ignore_localhost?' do
7
- [true, false].each do |val|
8
- it "returns #{val} when ignore_localhost is set to #{val}" do
9
- subject.ignore_localhost = val
10
- subject.ignore_localhost?.should == val
11
- end
12
- end
13
-
14
- it "returns false when ignore_localhost is set to nil" do
15
- subject.ignore_localhost = nil
16
- subject.ignore_localhost?.should == false
17
- end
18
- end
19
-
20
6
  describe '.set_http_connections_allowed_to_default' do
21
7
  [true, false].each do |default|
22
8
  context "when VCR::Config.allow_http_connections_when_no_cassette is #{default}" do
@@ -59,7 +45,7 @@ shared_examples_for "an http stubbing adapter" do |supported_http_libraries, sup
59
45
  end
60
46
 
61
47
  if other.include?(:needs_net_http_extension)
62
- describe '#request_uri' do
48
+ describe '.request_uri' do
63
49
  it 'returns the uri for the given http request' do
64
50
  net_http = Net::HTTP.new('example.com', 80)
65
51
  request = Net::HTTP::Get.new('/foo/bar')
@@ -74,7 +60,7 @@ shared_examples_for "an http stubbing adapter" do |supported_http_libraries, sup
74
60
  end
75
61
  end
76
62
 
77
- describe '#request_stubbed? using specific match_attributes' do
63
+ describe '.request_stubbed? using specific match_attributes' do
78
64
  let(:interactions) { YAML.load(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', YAML_SERIALIZATION_VERSION, 'match_requests_on.yml'))) }
79
65
 
80
66
  @supported_request_match_attributes = supported_request_match_attributes
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for "header normalization" do
4
+ let(:instance) do
5
+ with_headers('Some_Header' => 'value1', 'aNother' => ['a', 'b'], 'third' => [], 'fourth' => nil)
6
+ end
7
+
8
+ it 'normalizes the hash to lower case keys and arrays of values' do
9
+ instance.headers['some_header'].should == ['value1']
10
+ instance.headers['another'].should == ['a', 'b']
11
+ end
12
+
13
+ it 'removes empty headers' do
14
+ instance.headers.should_not have_key('third')
15
+ instance.headers.should_not have_key('fourth')
16
+ end
17
+
18
+ it 'filters out unimportant default values set by the HTTP library' do
19
+ instance = with_headers('accept' => ['*/*'], 'connection' => 'close', 'http-user' => ['foo'], 'expect' => ['', 'bar'])
20
+ instance.headers.should == { 'http-user' => ['foo'], 'expect' => ['bar'] }
21
+ end
22
+
23
+ it 'sets empty hash header to nil' do
24
+ with_headers({}).headers.should be_nil
25
+ end
26
+
27
+ it 'ensures header keys are serialized to yaml as raw strings' do
28
+ key = 'my-key'
29
+ key.instance_variable_set(:@foo, 7)
30
+ instance = with_headers(key => ['value1'])
31
+ instance.headers.to_yaml.should == { 'my-key' => ['value1'] }.to_yaml
32
+ end
33
+
34
+ it 'ensures header values are serialized to yaml as raw strings' do
35
+ value = 'my-value'
36
+ value.instance_variable_set(:@foo, 7)
37
+ instance = with_headers('my-key' => [value])
38
+ instance.headers.to_yaml.should == { 'my-key' => ['my-value'] }.to_yaml
39
+ end
40
+ end
41
+
42
+ shared_examples_for "body normalization" do
43
+ it 'sets empty string to nil' do
44
+ instance('').body.should be_nil
45
+ end
46
+
47
+ it "ensures the body is serialized to yaml as a raw string" do
48
+ body = "My String"
49
+ body.instance_variable_set(:@foo, 7)
50
+ instance(body).body.to_yaml.should == "My String".to_yaml
51
+ end
52
+ end
53
+
54
+ shared_examples_for 'uri normalization' do
55
+ it 'adds port 80 to an http URI that lacks a port' do
56
+ instance('http://example.com/foo').uri.should == 'http://example.com:80/foo'
57
+ end
58
+
59
+ it 'keeps the existing port for an http URI' do
60
+ instance('http://example.com:8000/foo').uri.should == 'http://example.com:8000/foo'
61
+ end
62
+
63
+ it 'adds port 443 to an https URI that lacks a port' do
64
+ instance('https://example.com/foo').uri.should == 'https://example.com:443/foo'
65
+ end
66
+
67
+ it 'keeps the existing port for an https URI' do
68
+ instance('https://example.com:8000/foo').uri.should == 'https://example.com:8000/foo'
69
+ end
70
+ end
71
+
72
+ shared_examples_for 'status message normalization' do
73
+ it 'chomps leading and trailing spaces on the status message' do
74
+ instance(' OK ').message.should == 'OK'
75
+ end
76
+
77
+ it 'sets status message to nil when it is the empty string' do
78
+ instance('').message.should be_nil
79
+ end
80
+
81
+ it 'sets status message to nil when it is a blank string' do
82
+ instance(' ').message.should be_nil
83
+ end
84
+ end
@@ -1,7 +1,7 @@
1
1
  shared_examples_for "version checking" do |options|
2
2
  library = described_class.library_name
3
3
 
4
- describe '#check_version!' do
4
+ describe '.check_version!' do
5
5
  options[:valid].each do |version|
6
6
  it "does nothing when #{library}'s version is #{version}" do
7
7
  stub_version(version)
@@ -49,7 +49,7 @@ describe VCR::Cassette do
49
49
  end
50
50
  end
51
51
 
52
- describe 'on creation' do
52
+ describe '.new' do
53
53
  it 'raises an error with a helpful message when loading an old unsupported cassette' do
54
54
  VCR::Config.cassette_library_dir = "#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}"
55
55
  expect { VCR::Cassette.new('0_3_1_cassette') }.to raise_error(/The VCR cassette 0_3_1_cassette.yml uses an old format that is now deprecated/)
@@ -181,16 +181,14 @@ describe VCR::Cassette do
181
181
  VCR::Cassette.new(:name, :record => record_mode)
182
182
  end
183
183
 
184
- [true, false].each do |ignore_localhost|
185
- expected_uri_hosts = %w(example.com)
186
- expected_uri_hosts += VCR::LOCALHOST_ALIASES unless ignore_localhost
187
-
188
- it "#{ ignore_localhost ? 'does not load' : 'loads' } localhost interactions from the cassette file when http_stubbing_adapter.ignore_localhost is set to #{ignore_localhost}" do
189
- VCR.http_stubbing_adapter.stub!(:ignore_localhost?).and_return(ignore_localhost)
190
- VCR::Config.cassette_library_dir = "#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/cassette_spec"
191
- cassette = VCR::Cassette.new('with_localhost_requests', :record => record_mode)
192
- cassette.recorded_interactions.map { |i| URI.parse(i.uri).host }.should =~ expected_uri_hosts
184
+ it 'does not load ignored interactions' do
185
+ VCR::Config.stub(:uri_should_be_ignored?) do |uri|
186
+ uri.to_s !~ /example\.com/
193
187
  end
188
+
189
+ VCR::Config.cassette_library_dir = "#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/cassette_spec"
190
+ cassette = VCR::Cassette.new('with_localhost_requests', :record => record_mode)
191
+ cassette.recorded_interactions.map { |i| URI.parse(i.uri).host }.should == %w[example.com]
194
192
  end
195
193
 
196
194
  it "loads the recorded interactions from the library yml file" do
@@ -6,7 +6,7 @@ describe VCR::Config do
6
6
  VCR::Config.stub(:http_stubbing_libraries).and_return([])
7
7
  end
8
8
 
9
- describe '#cassette_library_dir=' do
9
+ describe '.cassette_library_dir=' do
10
10
  temp_dir(File.expand_path(File.dirname(__FILE__) + '/fixtures/config_spec'))
11
11
 
12
12
  it 'creates the directory if it does not exist' do
@@ -18,7 +18,7 @@ describe VCR::Config do
18
18
  end
19
19
  end
20
20
 
21
- describe '#default_cassette_options' do
21
+ describe '.default_cassette_options' do
22
22
  it 'has a hash with some defaults even if it is set to nil' do
23
23
  VCR::Config.default_cassette_options = nil
24
24
  VCR::Config.default_cassette_options.should == { :match_requests_on => VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES }
@@ -47,26 +47,52 @@ describe VCR::Config do
47
47
  end
48
48
  end
49
49
 
50
- describe '#ignore_localhost' do
51
- it 'sets VCR.http_stubbing_adapter.ignore_localhost?' do
52
- [true, false].each do |val|
53
- VCR.http_stubbing_adapter.ignore_localhost = !val
54
- expect {
55
- VCR::Config.ignore_localhost = val
56
- }.to change { VCR.http_stubbing_adapter.ignore_localhost? }.from(!val).to(val)
57
- end
50
+ describe '.ignore_hosts' do
51
+ let(:stubbing_adapter) { VCR::HttpStubbingAdapters::FakeWeb }
52
+ before(:each) do
53
+ stubbing_adapter.send(:ignored_hosts).should be_empty
54
+ VCR.stub(:http_stubbing_adapter => stubbing_adapter)
55
+ VCR::Config.ignored_hosts.should be_empty
58
56
  end
59
57
 
60
- it 'stores the value even when VCR.http_stubbing_adapter is not set' do
61
- stub_no_http_stubbing_adapter
62
- [true, false].each do |val|
63
- VCR::Config.ignore_localhost = val
64
- VCR::Config.ignore_localhost?.should == val
65
- end
58
+ it 'adds the given hosts to the ignored_hosts list' do
59
+ VCR::Config.ignore_hosts 'example.com', 'example.net'
60
+ VCR::Config.ignored_hosts.should == %w[ example.com example.net ]
61
+ VCR::Config.ignore_host 'example.org'
62
+ VCR::Config.ignored_hosts.should == %w[ example.com example.net example.org ]
63
+ end
64
+
65
+ it 'removes duplicate hosts' do
66
+ VCR::Config.ignore_host 'example.com'
67
+ VCR::Config.ignore_host 'example.com'
68
+ VCR::Config.ignored_hosts.should == ['example.com']
69
+ end
70
+
71
+ it "updates the http_stubbing_adapter's ignored_hosts list" do
72
+ VCR::Config.ignore_hosts 'example.com', 'example.org'
73
+ stubbing_adapter.send(:ignored_hosts).should == %w[ example.com example.org ]
74
+ end
75
+ end
76
+
77
+ describe '.ignore_localhost=' do
78
+ before(:each) do
79
+ VCR::Config.ignored_hosts.should be_empty
80
+ end
81
+
82
+ it 'adds the localhost aliases to the ignored_hosts list when set to true' do
83
+ VCR::Config.ignore_host 'example.com'
84
+ VCR::Config.ignore_localhost = true
85
+ VCR::Config.ignored_hosts.should == ['example.com', *VCR::LOCALHOST_ALIASES]
86
+ end
87
+
88
+ it 'removes the localhost aliases from the ignored_hosts list when set to false' do
89
+ VCR::Config.ignore_host 'example.com', *VCR::LOCALHOST_ALIASES
90
+ VCR::Config.ignore_localhost = false
91
+ VCR::Config.ignored_hosts.should == ['example.com']
66
92
  end
67
93
  end
68
94
 
69
- describe '#allow_http_connections_when_no_cassette=' do
95
+ describe '.allow_http_connections_when_no_cassette=' do
70
96
  [true, false].each do |val|
71
97
  it "sets the allow_http_connections_when_no_cassette to #{val} when set to #{val}" do
72
98
  VCR::Config.allow_http_connections_when_no_cassette = val
@@ -85,4 +111,24 @@ describe VCR::Config do
85
111
  VCR::Config.allow_http_connections_when_no_cassette = true
86
112
  end
87
113
  end
114
+
115
+ describe '.uri_should_be_ignored?' do
116
+ before(:each) { described_class.ignore_hosts 'example.com' }
117
+
118
+ it 'returns true for a string URI with a host in the ignore_hosts list' do
119
+ described_class.uri_should_be_ignored?("http://example.com/").should be_true
120
+ end
121
+
122
+ it 'returns true for a URI instance with a host in the ignore_hosts list' do
123
+ described_class.uri_should_be_ignored?(URI("http://example.com/")).should be_true
124
+ end
125
+
126
+ it 'returns false for a string URI with a host in the ignore_hosts list' do
127
+ described_class.uri_should_be_ignored?("http://example.net/").should be_false
128
+ end
129
+
130
+ it 'returns false for a URI instance with a host in the ignore_hosts list' do
131
+ described_class.uri_should_be_ignored?(URI("http://example.net/")).should be_false
132
+ end
133
+ end
88
134
  end
@@ -1,8 +1,58 @@
1
1
  require 'spec_helper'
2
2
 
3
+ shared_examples_for '.ignore_localhost? deprecation' do
4
+ it 'returns false when no hosts are ignored' do
5
+ VCR::Config.ignored_hosts.should be_empty
6
+ described_class.ignore_localhost?.should be_false
7
+ end
8
+
9
+ it 'returns false when only non-local hosts are ignored' do
10
+ VCR::Config.ignore_hosts 'example.com'
11
+ described_class.ignore_localhost?.should be_false
12
+ end
13
+
14
+ it 'returns false when only some localhost aliases are ignored' do
15
+ aliases = VCR::LOCALHOST_ALIASES.dup
16
+ aliases.pop
17
+ VCR::Config.ignore_hosts *aliases
18
+ described_class.ignore_localhost?.should be_false
19
+ end
20
+
21
+ it 'returns true when all localhost aliases are ignored, even if some other hosts are ignored, too' do
22
+ VCR::Config.ignore_hosts 'example.com', *VCR::LOCALHOST_ALIASES
23
+ described_class.ignore_localhost?.should be_true
24
+ end
25
+
26
+ it 'prints a warning: WARNING: `VCR::Config.ignore_localhost?` is deprecated. Check the list of ignored hosts using `VCR::Config.ignored_hosts` instead.' do
27
+ VCR::Config.should_receive(:warn).with(/Check the list of ignored hosts using `VCR::Config.ignored_hosts` instead/)
28
+ described_class.ignore_localhost?
29
+ end
30
+ end
31
+
3
32
  describe 'Deprecations' do
4
33
  disable_warnings
5
34
 
35
+ VCR::HttpStubbingAdapters::Common.adapters.each do |adapter|
36
+ describe adapter do
37
+ it_behaves_like '.ignore_localhost? deprecation'
38
+ end
39
+ end
40
+
41
+ describe VCR::HttpStubbingAdapters::FakeWeb do
42
+ describe 'LOCALHOST_REGEX constant' do
43
+ subject { described_class::LOCALHOST_REGEX }
44
+
45
+ it 'refers to the expected regex' do
46
+ should == %r|\Ahttps?://((\w+:)?\w+@)?(#{VCR::LOCALHOST_ALIASES.sort.map { |a| Regexp.escape(a) }.join('|')})(:\d+)?/|i
47
+ end
48
+
49
+ it 'prints a warning: WARNING: `VCR::HttpStubbingAdapters::FakeWeb::LOCALHOST_REGEX` is deprecated.' do
50
+ described_class.should_receive(:warn).with("WARNING: `VCR::HttpStubbingAdapters::FakeWeb::LOCALHOST_REGEX` is deprecated.")
51
+ subject
52
+ end
53
+ end
54
+ end
55
+
6
56
  describe VCR::Config do
7
57
  describe '.http_stubbing_library' do
8
58
  before(:each) { described_class.stub_with :webmock, :typhoeus }
@@ -28,6 +78,8 @@ describe 'Deprecations' do
28
78
  described_class.http_stubbing_library = :webmock
29
79
  end
30
80
  end
81
+
82
+ it_behaves_like '.ignore_localhost? deprecation'
31
83
  end
32
84
 
33
85
  describe VCR::Cassette do
@@ -43,35 +95,42 @@ describe 'Deprecations' do
43
95
  end
44
96
 
45
97
  [true, false].each do |orig_ignore_localhost|
46
- context "when the http_stubbing_adapter's ignore_localhost is set to #{orig_ignore_localhost}" do
47
- before(:each) { VCR.http_stubbing_adapter.ignore_localhost = orig_ignore_localhost }
98
+ orig_ignored_hosts = if orig_ignore_localhost
99
+ VCR::LOCALHOST_ALIASES
100
+ else
101
+ []
102
+ end
48
103
 
49
- context 'when the :allow_real_http option is set to :localhost' do
50
- subject { VCR::Cassette.new('cassette name', :allow_real_http => :localhost) }
104
+ context "when the ignored_hosts list is set to #{orig_ignored_hosts.inspect} and the :allow_real_http option is set to :localhost" do
105
+ before(:each) do
106
+ VCR::Config.ignored_hosts.clear
107
+ VCR::Config.ignore_hosts *orig_ignored_hosts
108
+ end
51
109
 
52
- it "sets the http_stubbing_adapter's ignore_localhost attribute to true" do
53
- subject
54
- VCR.http_stubbing_adapter.ignore_localhost?.should == true
55
- end
110
+ subject { VCR::Cassette.new('cassette name', :allow_real_http => :localhost) }
56
111
 
57
- it "prints a warning: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option." do
58
- Kernel.should_receive(:warn).with("WARNING: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option.")
59
- subject
60
- end
112
+ it "sets the ignored_hosts list to the list of localhost aliases" do
113
+ subject
114
+ VCR::Config.ignored_hosts.should == VCR::LOCALHOST_ALIASES
115
+ end
61
116
 
62
- it "reverts ignore_localhost when the cassette is ejected" do
63
- subject.eject
64
- VCR.http_stubbing_adapter.ignore_localhost?.should == orig_ignore_localhost
65
- end
117
+ it "prints a warning: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option." do
118
+ Kernel.should_receive(:warn).with("WARNING: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option.")
119
+ subject
120
+ end
121
+
122
+ it "reverts ignore_hosts when the cassette is ejected" do
123
+ subject.eject
124
+ VCR::Config.ignored_hosts.should == orig_ignored_hosts
125
+ end
66
126
 
67
- {
68
- 'http://localhost' => true,
69
- 'http://127.0.0.1' => true,
70
- 'http://example.com' => false
71
- }.each do |url, expected_value|
72
- it "returns #{expected_value} for #allow_real_http_requests_to? when it is given #{url}" do
73
- subject.allow_real_http_requests_to?(URI.parse(url)).should == expected_value
74
- end
127
+ {
128
+ 'http://localhost' => true,
129
+ 'http://127.0.0.1' => true,
130
+ 'http://example.com' => false
131
+ }.each do |url, expected_value|
132
+ it "returns #{expected_value} for #allow_real_http_requests_to? when it is given #{url}" do
133
+ subject.allow_real_http_requests_to?(URI.parse(url)).should == expected_value
75
134
  end
76
135
  end
77
136
  end