vcr 1.11.1 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +3 -0
- data/CHANGELOG.md +11 -4
- data/Gemfile +5 -4
- data/Rakefile +23 -4
- data/cucumber.yml +2 -2
- data/features/cassettes/automatic_re_recording.feature +2 -2
- data/features/cassettes/dynamic_erb.feature +2 -2
- data/features/cassettes/format.feature +1 -1
- data/features/cassettes/naming.feature +1 -1
- data/features/cassettes/no_cassette.feature +4 -4
- data/features/cassettes/request_matching.feature +5 -5
- data/features/cassettes/update_content_length_header.feature +3 -3
- data/features/configuration/allow_http_connections_when_no_cassette.feature +3 -3
- data/features/configuration/cassette_library_dir.feature +1 -1
- data/features/configuration/default_cassette_options.feature +5 -5
- data/features/configuration/filter_sensitive_data.feature +6 -6
- data/features/configuration/hooks.feature +6 -6
- data/features/configuration/ignore_hosts.feature +1 -1
- data/features/configuration/ignore_localhost.feature +2 -2
- data/features/configuration/stub_with.feature +4 -4
- data/features/http_libraries/em_http_request.feature +4 -4
- data/features/http_libraries/net_http.feature +10 -10
- data/features/middleware/faraday.feature +2 -2
- data/features/middleware/rack.feature +2 -2
- data/features/record_modes/all.feature +2 -2
- data/features/record_modes/new_episodes.feature +2 -2
- data/features/record_modes/none.feature +2 -2
- data/features/record_modes/once.feature +3 -3
- data/features/step_definitions/cli_steps.rb +6 -2
- data/features/support/env.rb +5 -8
- data/features/support/http_lib_filters.rb +6 -1
- data/features/test_frameworks/cucumber.feature +2 -2
- data/features/test_frameworks/rspec.feature +2 -2
- data/features/test_frameworks/shoulda.feature +13 -10
- data/features/test_frameworks/test_unit.feature +12 -9
- data/lib/vcr.rb +6 -0
- data/lib/vcr/config.rb +7 -1
- data/lib/vcr/deprecations/cassette.rb +16 -16
- data/lib/vcr/extensions/net_http_response.rb +4 -0
- data/lib/vcr/http_stubbing_adapters/common.rb +1 -1
- data/lib/vcr/http_stubbing_adapters/fakeweb.rb +6 -0
- data/lib/vcr/http_stubbing_adapters/webmock.rb +7 -0
- data/lib/vcr/middleware/cassette_arguments.rb +1 -0
- data/lib/vcr/structs/http_interaction.rb +1 -0
- data/lib/vcr/version.rb +1 -1
- data/spec/capture_warnings.rb +42 -0
- data/spec/monkey_patches.rb +5 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/support/shared_example_groups/http_library.rb +19 -19
- data/spec/support/shared_example_groups/http_stubbing_adapter.rb +6 -6
- data/spec/support/shared_example_groups/ignore_localhost_deprecation.rb +1 -1
- data/spec/support/shared_example_groups/normalizers.rb +13 -15
- data/spec/support/sinatra_app.rb +2 -0
- data/spec/support/vcr_localhost_server.rb +4 -3
- data/spec/vcr/cassette/reader_spec.rb +4 -4
- data/spec/vcr/cassette_spec.rb +28 -28
- data/spec/vcr/config_spec.rb +11 -11
- data/spec/vcr/deprecations/cassette_spec.rb +4 -4
- data/spec/vcr/deprecations/config_spec.rb +2 -2
- data/spec/vcr/deprecations/http_stubbing_adapters/fakeweb_spec.rb +1 -1
- data/spec/vcr/extensions/net_http_response_spec.rb +3 -3
- data/spec/vcr/extensions/net_http_spec.rb +4 -4
- data/spec/vcr/http_stubbing_adapters/excon_spec.rb +5 -5
- data/spec/vcr/http_stubbing_adapters/faraday_spec.rb +4 -4
- data/spec/vcr/http_stubbing_adapters/multi_object_proxy_spec.rb +4 -4
- data/spec/vcr/middleware/cassette_arguments_spec.rb +5 -5
- data/spec/vcr/middleware/faraday_spec.rb +3 -3
- data/spec/vcr/middleware/rack_spec.rb +4 -4
- data/spec/vcr/request_matcher_spec.rb +13 -13
- data/spec/vcr/structs/http_interaction_spec.rb +6 -6
- data/spec/vcr/structs/request_spec.rb +7 -7
- data/spec/vcr/structs/response_spec.rb +5 -5
- data/spec/vcr/structs/response_status_spec.rb +2 -2
- data/spec/vcr/test_frameworks/cucumber_spec.rb +2 -2
- data/spec/vcr/test_frameworks/rspec_spec.rb +6 -7
- data/spec/vcr/util/hooks_spec.rb +9 -9
- data/spec/vcr_spec.rb +11 -17
- data/vcr.gemspec +11 -5
- metadata +47 -49
- data/features/support/aruba_workaround/aruba_patches.rb +0 -36
- data/features/support/aruba_workaround/background_process.rb +0 -4
data/spec/support/sinatra_app.rb
CHANGED
@@ -6,6 +6,8 @@ require 'net/http'
|
|
6
6
|
# http://github.com/jnicklas/capybara/blob/0.3.9/lib/capybara/server.rb
|
7
7
|
module VCR
|
8
8
|
class LocalhostServer
|
9
|
+
READY_MESSAGE = "VCR server ready"
|
10
|
+
|
9
11
|
class Identify
|
10
12
|
def initialize(app)
|
11
13
|
@app = app
|
@@ -13,7 +15,7 @@ module VCR
|
|
13
15
|
|
14
16
|
def call(env)
|
15
17
|
if env["PATH_INFO"] == "/__identify__"
|
16
|
-
[200, {}, [
|
18
|
+
[200, {}, [VCR::LocalhostServer::READY_MESSAGE]]
|
17
19
|
else
|
18
20
|
@app.call(env)
|
19
21
|
end
|
@@ -47,9 +49,8 @@ module VCR
|
|
47
49
|
|
48
50
|
def booted?
|
49
51
|
res = ::Net::HTTP.get_response("localhost", '/__identify__', port)
|
50
|
-
|
51
52
|
if res.is_a?(::Net::HTTPSuccess) or res.is_a?(::Net::HTTPRedirection)
|
52
|
-
return res.body ==
|
53
|
+
return res.body == READY_MESSAGE
|
53
54
|
end
|
54
55
|
rescue Errno::ECONNREFUSED, Errno::EBADF
|
55
56
|
return false
|
@@ -21,14 +21,14 @@ describe VCR::Cassette::Reader do
|
|
21
21
|
|
22
22
|
context 'when ERB is disabled' do
|
23
23
|
it 'reads the raw file content' do
|
24
|
-
read('no_vars', false).should
|
25
|
-
read('no_vars', nil).should
|
24
|
+
read('no_vars', false).should eq(no_vars_content)
|
25
|
+
read('no_vars', nil).should eq(no_vars_content)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'when ERB is enabled but no variables are passed' do
|
30
30
|
it 'renders the file content as ERB' do
|
31
|
-
read('no_vars', true).should
|
31
|
+
read('no_vars', true).should eq("7. Some ERB")
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'raises an appropriate error when the ERB template needs variables' do
|
@@ -43,7 +43,7 @@ describe VCR::Cassette::Reader do
|
|
43
43
|
|
44
44
|
context 'when ERB is enabled and variables are passed' do
|
45
45
|
it 'renders the file content as ERB with the passed variables' do
|
46
|
-
read('vars', :var1 => 'foo', :var2 => 'bar').should
|
46
|
+
read('vars', :var1 => 'foo', :var2 => 'bar').should eq('foo. ERB with Vars! bar')
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'raises an appropriate error when one or more of the needed variables are not passed' do
|
data/spec/vcr/cassette_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe VCR::Cassette do
|
|
4
4
|
describe '#file' do
|
5
5
|
it 'combines the cassette_library_dir with the cassette name' do
|
6
6
|
cassette = VCR::Cassette.new('the_file')
|
7
|
-
cassette.file.should
|
7
|
+
cassette.file.should eq(File.join(VCR::Config.cassette_library_dir, 'the_file.yml'))
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'strips out disallowed characters so that it is a valid file name with no spaces' do
|
@@ -27,9 +27,9 @@ describe VCR::Cassette do
|
|
27
27
|
describe '#record_http_interaction' do
|
28
28
|
it 'adds the interaction to #new_recorded_interactions' do
|
29
29
|
cassette = VCR::Cassette.new(:test_cassette)
|
30
|
-
cassette.new_recorded_interactions.should
|
30
|
+
cassette.new_recorded_interactions.should eq([])
|
31
31
|
cassette.record_http_interaction(:the_interaction)
|
32
|
-
cassette.new_recorded_interactions.should
|
32
|
+
cassette.new_recorded_interactions.should eq([:the_interaction])
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -38,12 +38,12 @@ describe VCR::Cassette do
|
|
38
38
|
|
39
39
|
it "returns the provided options" do
|
40
40
|
c = VCR::Cassette.new('example', :match_requests_on => [:uri])
|
41
|
-
c.match_requests_on.should
|
41
|
+
c.match_requests_on.should eq([:uri])
|
42
42
|
end
|
43
43
|
|
44
44
|
it "returns a the default #match_requests_on when it has not been specified for the cassette" do
|
45
45
|
c = VCR::Cassette.new('example')
|
46
|
-
c.match_requests_on.should
|
46
|
+
c.match_requests_on.should eq([:uri, :method])
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -65,7 +65,7 @@ describe VCR::Cassette do
|
|
65
65
|
|
66
66
|
it 'does not raise an error in the case of an empty file' do
|
67
67
|
VCR::Config.cassette_library_dir = "#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/cassette_spec"
|
68
|
-
VCR::Cassette.new('empty', :record => :none).recorded_interactions.should
|
68
|
+
VCR::Cassette.new('empty', :record => :none).recorded_interactions.should eq([])
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'creates a stubs checkpoint on the http_stubbing_adapter' do
|
@@ -124,7 +124,7 @@ describe VCR::Cassette do
|
|
124
124
|
|
125
125
|
it "defaults the record mode to #{record_mode} when VCR::Config.default_cassette_options[:record] is #{record_mode}" do
|
126
126
|
cassette = VCR::Cassette.new(:test)
|
127
|
-
cassette.record_mode.should
|
127
|
+
cassette.record_mode.should eq(record_mode)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -186,7 +186,7 @@ describe VCR::Cassette do
|
|
186
186
|
before(:each) { File.stub(:exist?).with(file_name).and_return(false) }
|
187
187
|
|
188
188
|
it "has :#{record_mode} for the record mode" do
|
189
|
-
subject.record_mode.should
|
189
|
+
subject.record_mode.should eq(record_mode)
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
@@ -200,7 +200,7 @@ describe VCR::Cassette do
|
|
200
200
|
before(:each) { File.stub(:stat).with(file_name).and_return(stub(:mtime => Time.now - 7.days + 60)) }
|
201
201
|
|
202
202
|
it "has :#{record_mode} for the record mode" do
|
203
|
-
subject.record_mode.should
|
203
|
+
subject.record_mode.should eq(record_mode)
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
@@ -209,12 +209,12 @@ describe VCR::Cassette do
|
|
209
209
|
|
210
210
|
it "has :all for the record mode when there is an internet connection available" do
|
211
211
|
VCR::InternetConnection.stub(:available? => true)
|
212
|
-
subject.record_mode.should
|
212
|
+
subject.record_mode.should eq(:all)
|
213
213
|
end
|
214
214
|
|
215
215
|
it "has :#{record_mode} for the record mode when there is no internet connection available" do
|
216
216
|
VCR::InternetConnection.stub(:available? => false)
|
217
|
-
subject.record_mode.should
|
217
|
+
subject.record_mode.should eq(record_mode)
|
218
218
|
end
|
219
219
|
end
|
220
220
|
end
|
@@ -233,7 +233,7 @@ describe VCR::Cassette do
|
|
233
233
|
|
234
234
|
VCR::Config.cassette_library_dir = "#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/cassette_spec"
|
235
235
|
cassette = VCR::Cassette.new('with_localhost_requests', :record => record_mode)
|
236
|
-
cassette.recorded_interactions.map { |i| URI.parse(i.uri).host }.should
|
236
|
+
cassette.recorded_interactions.map { |i| URI.parse(i.uri).host }.should eq(%w[example.com])
|
237
237
|
end
|
238
238
|
|
239
239
|
it "loads the recorded interactions from the library yml file" do
|
@@ -244,16 +244,16 @@ describe VCR::Cassette do
|
|
244
244
|
|
245
245
|
i1, i2, i3 = *cassette.recorded_interactions
|
246
246
|
|
247
|
-
i1.request.method.should
|
248
|
-
i1.request.uri.should
|
247
|
+
i1.request.method.should eq(:get)
|
248
|
+
i1.request.uri.should eq('http://example.com:80/')
|
249
249
|
i1.response.body.should =~ /You have reached this web page by typing.+example\.com/
|
250
250
|
|
251
|
-
i2.request.method.should
|
252
|
-
i2.request.uri.should
|
251
|
+
i2.request.method.should eq(:get)
|
252
|
+
i2.request.uri.should eq('http://example.com:80/foo')
|
253
253
|
i2.response.body.should =~ /foo was not found on this server/
|
254
254
|
|
255
|
-
i3.request.method.should
|
256
|
-
i3.request.uri.should
|
255
|
+
i3.request.method.should eq(:get)
|
256
|
+
i3.request.uri.should eq('http://example.com:80/')
|
257
257
|
i3.response.body.should =~ /Another example\.com response/
|
258
258
|
end
|
259
259
|
|
@@ -283,19 +283,19 @@ describe VCR::Cassette do
|
|
283
283
|
it "stubs the recorded requests with the http stubbing adapter" do
|
284
284
|
VCR::Config.cassette_library_dir = "#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/cassette_spec"
|
285
285
|
VCR.http_stubbing_adapter.should_receive(:stub_requests).with([an_instance_of(VCR::HTTPInteraction)]*3, anything)
|
286
|
-
|
286
|
+
VCR::Cassette.new('example', :record => record_mode)
|
287
287
|
end
|
288
288
|
|
289
289
|
it "passes the :match_request_on option to #stub_requests" do
|
290
290
|
VCR::Config.cassette_library_dir = "#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/cassette_spec"
|
291
291
|
VCR.http_stubbing_adapter.should_receive(:stub_requests).with(anything, [:body, :headers])
|
292
|
-
|
292
|
+
VCR::Cassette.new('example', :record => record_mode, :match_requests_on => [:body, :headers])
|
293
293
|
end
|
294
294
|
else
|
295
295
|
it "does not stub the recorded requests with the http stubbing adapter" do
|
296
296
|
VCR::Config.cassette_library_dir = "#{VCR::SPEC_ROOT}/fixtures/#{YAML_SERIALIZATION_VERSION}/cassette_spec"
|
297
297
|
VCR.http_stubbing_adapter.should_not_receive(:stub_requests)
|
298
|
-
|
298
|
+
VCR::Cassette.new('example', :record => record_mode)
|
299
299
|
end
|
300
300
|
end
|
301
301
|
end
|
@@ -324,7 +324,7 @@ describe VCR::Cassette do
|
|
324
324
|
|
325
325
|
expect { cassette.eject }.to change { File.exist?(cassette.file) }.from(false).to(true)
|
326
326
|
saved_recorded_interactions = VCR::YAML.load_file(cassette.file)
|
327
|
-
saved_recorded_interactions.should
|
327
|
+
saved_recorded_interactions.should eq(recorded_interactions)
|
328
328
|
end
|
329
329
|
|
330
330
|
it 'invokes the appropriately tagged before_record hooks' do
|
@@ -359,7 +359,7 @@ describe VCR::Cassette do
|
|
359
359
|
cassette.eject
|
360
360
|
|
361
361
|
saved_recorded_interactions = VCR::YAML.load_file(cassette.file)
|
362
|
-
saved_recorded_interactions.should
|
362
|
+
saved_recorded_interactions.should eq([interaction_2])
|
363
363
|
end
|
364
364
|
|
365
365
|
it 'does not write the cassette to disk if all interactions have been ignored' do
|
@@ -380,7 +380,7 @@ describe VCR::Cassette do
|
|
380
380
|
|
381
381
|
expect { cassette.eject }.to change { File.exist?(cassette.file) }.from(false).to(true)
|
382
382
|
saved_recorded_interactions = VCR::YAML.load_file(cassette.file)
|
383
|
-
saved_recorded_interactions.should
|
383
|
+
saved_recorded_interactions.should eq(recorded_interactions)
|
384
384
|
end
|
385
385
|
|
386
386
|
[:all, :none, :new_episodes].each do |record_mode|
|
@@ -440,12 +440,12 @@ describe VCR::Cassette do
|
|
440
440
|
it 'removes the old interactions that match new requests, and saves the new interactions follow the old ones' do
|
441
441
|
subject.eject
|
442
442
|
|
443
|
-
saved_recorded_interactions.should
|
443
|
+
saved_recorded_interactions.should eq([
|
444
444
|
old_interaction_2,
|
445
445
|
new_interaction_1,
|
446
446
|
new_interaction_2,
|
447
447
|
new_interaction_3
|
448
|
-
]
|
448
|
+
])
|
449
449
|
end
|
450
450
|
|
451
451
|
it "matches old requests to new ones using the cassette's match attributes" do
|
@@ -464,14 +464,14 @@ describe VCR::Cassette do
|
|
464
464
|
it 'saves the old interactions followed by the new ones to disk' do
|
465
465
|
subject.eject
|
466
466
|
|
467
|
-
saved_recorded_interactions.should
|
467
|
+
saved_recorded_interactions.should eq([
|
468
468
|
old_interaction_1,
|
469
469
|
old_interaction_2,
|
470
470
|
old_interaction_3,
|
471
471
|
new_interaction_1,
|
472
472
|
new_interaction_2,
|
473
473
|
new_interaction_3
|
474
|
-
]
|
474
|
+
])
|
475
475
|
end
|
476
476
|
end
|
477
477
|
end
|
data/spec/vcr/config_spec.rb
CHANGED
@@ -22,10 +22,10 @@ describe VCR::Config do
|
|
22
22
|
describe '.default_cassette_options' do
|
23
23
|
it 'has a hash with some defaults even if it is set to nil' do
|
24
24
|
VCR::Config.default_cassette_options = nil
|
25
|
-
VCR::Config.default_cassette_options.should
|
25
|
+
VCR::Config.default_cassette_options.should eq({
|
26
26
|
:match_requests_on => VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES,
|
27
27
|
:record => :once
|
28
|
-
}
|
28
|
+
})
|
29
29
|
end
|
30
30
|
|
31
31
|
it "returns #{VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES.inspect} for :match_requests_on when other defaults have been set" do
|
@@ -42,14 +42,14 @@ describe VCR::Config do
|
|
42
42
|
describe '.stub_with' do
|
43
43
|
it 'stores the given symbols in http_stubbing_libraries' do
|
44
44
|
VCR::Config.stub_with :fakeweb, :typhoeus
|
45
|
-
VCR::Config.http_stubbing_libraries.should
|
45
|
+
VCR::Config.http_stubbing_libraries.should eq([:fakeweb, :typhoeus])
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe '.http_stubbing_libraries' do
|
50
50
|
it 'returns an empty array even when the variable is nil' do
|
51
51
|
VCR::Config.send(:remove_instance_variable, :@http_stubbing_libraries)
|
52
|
-
VCR::Config.http_stubbing_libraries.should
|
52
|
+
VCR::Config.http_stubbing_libraries.should eq([])
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -63,20 +63,20 @@ describe VCR::Config do
|
|
63
63
|
|
64
64
|
it 'adds the given hosts to the ignored_hosts list' do
|
65
65
|
VCR::Config.ignore_hosts 'example.com', 'example.net'
|
66
|
-
VCR::Config.ignored_hosts.should
|
66
|
+
VCR::Config.ignored_hosts.should eq(%w[ example.com example.net ])
|
67
67
|
VCR::Config.ignore_host 'example.org'
|
68
|
-
VCR::Config.ignored_hosts.should
|
68
|
+
VCR::Config.ignored_hosts.should eq(%w[ example.com example.net example.org ])
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'removes duplicate hosts' do
|
72
72
|
VCR::Config.ignore_host 'example.com'
|
73
73
|
VCR::Config.ignore_host 'example.com'
|
74
|
-
VCR::Config.ignored_hosts.should
|
74
|
+
VCR::Config.ignored_hosts.should eq(['example.com'])
|
75
75
|
end
|
76
76
|
|
77
77
|
it "updates the http_stubbing_adapter's ignored_hosts list" do
|
78
78
|
VCR::Config.ignore_hosts 'example.com', 'example.org'
|
79
|
-
stubbing_adapter.send(:ignored_hosts).should
|
79
|
+
stubbing_adapter.send(:ignored_hosts).should eq(%w[ example.com example.org ])
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -88,13 +88,13 @@ describe VCR::Config do
|
|
88
88
|
it 'adds the localhost aliases to the ignored_hosts list when set to true' do
|
89
89
|
VCR::Config.ignore_host 'example.com'
|
90
90
|
VCR::Config.ignore_localhost = true
|
91
|
-
VCR::Config.ignored_hosts.should
|
91
|
+
VCR::Config.ignored_hosts.should eq(['example.com', *VCR::LOCALHOST_ALIASES])
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'removes the localhost aliases from the ignored_hosts list when set to false' do
|
95
95
|
VCR::Config.ignore_host 'example.com', *VCR::LOCALHOST_ALIASES
|
96
96
|
VCR::Config.ignore_localhost = false
|
97
|
-
VCR::Config.ignored_hosts.should
|
97
|
+
VCR::Config.ignored_hosts.should eq(['example.com'])
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -102,7 +102,7 @@ describe VCR::Config do
|
|
102
102
|
[true, false].each do |val|
|
103
103
|
it "sets the allow_http_connections_when_no_cassette to #{val} when set to #{val}" do
|
104
104
|
VCR::Config.allow_http_connections_when_no_cassette = val
|
105
|
-
VCR::Config.allow_http_connections_when_no_cassette?.should
|
105
|
+
VCR::Config.allow_http_connections_when_no_cassette?.should eq(val)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -23,14 +23,14 @@ describe VCR::Cassette, 'deprecations', :disable_warnings => true do
|
|
23
23
|
context "when the ignored_hosts list is set to #{orig_ignored_hosts.inspect} and the :allow_real_http option is set to :localhost" do
|
24
24
|
before(:each) do
|
25
25
|
VCR::Config.ignored_hosts.clear
|
26
|
-
VCR::Config.ignore_hosts
|
26
|
+
VCR::Config.ignore_hosts(*orig_ignored_hosts)
|
27
27
|
end
|
28
28
|
|
29
29
|
subject { VCR::Cassette.new('cassette name', :allow_real_http => :localhost) }
|
30
30
|
|
31
31
|
it "sets the ignored_hosts list to the list of localhost aliases" do
|
32
32
|
subject
|
33
|
-
VCR::Config.ignored_hosts.should
|
33
|
+
VCR::Config.ignored_hosts.should eq(VCR::LOCALHOST_ALIASES)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "prints a warning: VCR's :allow_real_http cassette option is deprecated. Instead, use the ignore_localhost configuration option." do
|
@@ -40,7 +40,7 @@ describe VCR::Cassette, 'deprecations', :disable_warnings => true do
|
|
40
40
|
|
41
41
|
it "reverts ignore_hosts when the cassette is ejected" do
|
42
42
|
subject.eject
|
43
|
-
VCR::Config.ignored_hosts.should
|
43
|
+
VCR::Config.ignored_hosts.should eq(orig_ignored_hosts)
|
44
44
|
end
|
45
45
|
|
46
46
|
{
|
@@ -49,7 +49,7 @@ describe VCR::Cassette, 'deprecations', :disable_warnings => true do
|
|
49
49
|
'http://example.com' => false
|
50
50
|
}.each do |url, expected_value|
|
51
51
|
it "returns #{expected_value} for #allow_real_http_requests_to? when it is given #{url}" do
|
52
|
-
subject.allow_real_http_requests_to?(URI.parse(url)).should
|
52
|
+
subject.allow_real_http_requests_to?(URI.parse(url)).should eq(expected_value)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -5,7 +5,7 @@ describe VCR::Config, 'deprecations', :disable_warnings => true do
|
|
5
5
|
before(:each) { described_class.stub_with :webmock, :typhoeus }
|
6
6
|
|
7
7
|
it 'returns the first configured stubbing library' do
|
8
|
-
described_class.http_stubbing_library.should
|
8
|
+
described_class.http_stubbing_library.should eq(:webmock)
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'prints a warning: WARNING: VCR::Config.http_stubbing_library is deprecated. Use VCR::Config.http_stubbing_libraries instead' do
|
@@ -17,7 +17,7 @@ describe VCR::Config, 'deprecations', :disable_warnings => true do
|
|
17
17
|
describe '.http_stubbing_library=' do
|
18
18
|
it 'sets http_stubbing_libraries to an array of the given value' do
|
19
19
|
described_class.http_stubbing_library = :webmock
|
20
|
-
described_class.http_stubbing_libraries.should
|
20
|
+
described_class.http_stubbing_libraries.should eq([:webmock])
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'prints a warning: WARNING: VCR::Config.http_stubbing_library= is deprecated. Use VCR::Config.stub_with instead' do
|
@@ -5,7 +5,7 @@ describe VCR::HttpStubbingAdapters::FakeWeb, 'deprecations', :disable_warnings =
|
|
5
5
|
subject { described_class::LOCALHOST_REGEX }
|
6
6
|
|
7
7
|
it 'refers to the expected regex' do
|
8
|
-
should == %r|\Ahttps?://((\w+:)?\w+@)?(#{VCR::LOCALHOST_ALIASES.sort.map { |a| Regexp.escape(a) }.join('|')})(:\d+)?/|i
|
8
|
+
should be == %r|\Ahttps?://((\w+:)?\w+@)?(#{VCR::LOCALHOST_ALIASES.sort.map { |a| Regexp.escape(a) }.join('|')})(:\d+)?/|i
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'prints a warning: WARNING: `VCR::HttpStubbingAdapters::FakeWeb::LOCALHOST_REGEX` is deprecated.' do
|
@@ -12,7 +12,7 @@ describe VCR::Net::HTTPResponse do
|
|
12
12
|
|
13
13
|
it 'allows the body to be read using #read_body with a block' do
|
14
14
|
yielded_body = ''
|
15
|
-
|
15
|
+
response { |r| r.read_body { |s| yielded_body << s.to_s } }
|
16
16
|
yielded_body.should =~ expected_regex
|
17
17
|
end
|
18
18
|
|
@@ -20,7 +20,7 @@ describe VCR::Net::HTTPResponse do
|
|
20
20
|
dest = ''
|
21
21
|
ret_val = response { |r| r.read_body(dest) }.body
|
22
22
|
dest.to_s.should =~ expected_regex
|
23
|
-
ret_val.to_s.should
|
23
|
+
ret_val.to_s.should eq(dest)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'raises an ArgumentError if both a destination string and a block is given to #read_body' do
|
@@ -45,7 +45,7 @@ describe VCR::Net::HTTPResponse do
|
|
45
45
|
let(:http_verb_method) { :"request_#{http_verb}" }
|
46
46
|
|
47
47
|
def response(&block)
|
48
|
-
if @response && block
|
48
|
+
if defined?(@response) && block
|
49
49
|
block.call(@response)
|
50
50
|
return @response
|
51
51
|
end
|
@@ -8,8 +8,8 @@ describe "Net::HTTP Extensions", :with_monkey_patches => :vcr do
|
|
8
8
|
|
9
9
|
it 'checks if the request is stubbed using a VCR::Request' do
|
10
10
|
VCR.http_stubbing_adapter.should_receive(:request_stubbed?) do |request, _|
|
11
|
-
request.uri.should
|
12
|
-
request.method.should
|
11
|
+
request.uri.should eq("http://localhost:#{VCR::SinatraApp.port}/")
|
12
|
+
request.method.should eq(:get)
|
13
13
|
true
|
14
14
|
end
|
15
15
|
Net::HTTP.get(uri)
|
@@ -48,8 +48,8 @@ describe "Net::HTTP Extensions", :with_monkey_patches => :vcr do
|
|
48
48
|
|
49
49
|
it "records headers for which Net::HTTP usually sets defaults when the user manually sets their values" do
|
50
50
|
VCR.should_receive(:record_http_interaction) do |interaction|
|
51
|
-
interaction.request.headers['content-type'].should
|
52
|
-
interaction.request.headers['host'].should
|
51
|
+
interaction.request.headers['content-type'].should eq(['foo/bar'])
|
52
|
+
interaction.request.headers['host'].should eq(['my-example.com'])
|
53
53
|
end
|
54
54
|
Net::HTTP.new('localhost', VCR::SinatraApp.port).send_request('POST', '/', '', { 'Content-Type' => 'foo/bar', 'Host' => 'my-example.com' })
|
55
55
|
end
|