vcr 2.9.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/about_these_examples.md +1 -1
- data/features/cassettes/automatic_re_recording.feature +4 -4
- data/features/cassettes/decompress.feature +3 -3
- data/features/cassettes/exclusive.feature +11 -8
- data/features/cassettes/format.feature +135 -32
- data/features/cassettes/naming.feature +2 -2
- data/features/cassettes/no_cassette.feature +4 -4
- data/features/configuration/allow_http_connections_when_no_cassette.feature +6 -3
- data/features/configuration/cassette_library_dir.feature +2 -2
- data/features/configuration/debug_logging.feature +15 -8
- data/features/configuration/filter_sensitive_data.feature +8 -7
- data/features/configuration/hook_into.feature +8 -8
- data/features/configuration/ignore_request.feature +13 -14
- data/features/configuration/preserve_exact_body_bytes.feature +5 -5
- data/features/configuration/uri_parser.feature +15 -11
- data/features/hooks/after_http_request.feature +5 -4
- data/features/hooks/around_http_request.feature +3 -3
- data/features/hooks/before_http_request.feature +4 -2
- data/features/hooks/before_playback.feature +14 -15
- data/features/hooks/before_record.feature +10 -10
- data/features/http_libraries/em_http_request.feature +6 -3
- data/features/http_libraries/net_http.feature +15 -5
- data/features/middleware/faraday.feature +2 -2
- data/features/middleware/rack.feature +4 -4
- data/features/record_modes/all.feature +5 -5
- data/features/record_modes/new_episodes.feature +2 -2
- data/features/record_modes/once.feature +3 -3
- data/features/step_definitions/cli_steps.rb +37 -39
- data/features/support/env.rb +29 -26
- data/features/support/http_lib_filters.rb +0 -7
- data/features/test_frameworks/cucumber.feature +11 -10
- data/features/test_frameworks/rspec_macro.feature +5 -30
- data/features/test_frameworks/rspec_metadata.feature +9 -8
- data/features/test_frameworks/test_unit.feature +5 -2
- data/lib/vcr.rb +86 -14
- data/lib/vcr/cassette.rb +4 -2
- data/lib/vcr/cassette/serializers.rb +10 -8
- data/lib/vcr/cassette/serializers/compressed.rb +45 -0
- data/lib/vcr/configuration.rb +38 -17
- data/lib/vcr/library_hooks/fakeweb.rb +1 -0
- data/lib/vcr/library_hooks/faraday.rb +5 -1
- data/lib/vcr/middleware/faraday.rb +13 -9
- data/lib/vcr/test_frameworks/cucumber.rb +39 -5
- data/lib/vcr/version.rb +1 -1
- data/spec/acceptance/concurrency_spec.rb +51 -0
- data/spec/{vcr → lib/vcr}/cassette/erb_renderer_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/cassette/http_interaction_list_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/cassette/migrator_spec.rb +10 -9
- data/spec/{vcr → lib/vcr}/cassette/persisters/file_system_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/cassette/persisters_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/cassette/serializers_spec.rb +8 -2
- data/spec/{vcr → lib/vcr}/cassette_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/configuration_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/deprecations_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/errors_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/extensions/net_http_response_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/library_hooks/excon_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/library_hooks/fakeweb_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/library_hooks/faraday_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/library_hooks/typhoeus_0.4_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/library_hooks/typhoeus_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/library_hooks/webmock_spec.rb +2 -2
- data/spec/{vcr → lib/vcr}/library_hooks_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/middleware/faraday_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/middleware/rack_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/request_ignorer_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/request_matcher_registry_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/structs_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/test_frameworks/cucumber_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/test_frameworks/rspec_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/util/hooks_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/util/internet_connection_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/util/version_checker_spec.rb +0 -0
- data/spec/{vcr → lib/vcr}/version_spec.rb +0 -0
- data/spec/{vcr_spec.rb → lib/vcr_spec.rb} +2 -2
- data/spec/spec_helper.rb +21 -50
- data/spec/support/cucumber_helpers.rb +39 -0
- data/spec/support/limited_uri.rb +1 -11
- data/spec/support/shared_example_groups/hook_into_http_library.rb +2 -1
- data/spec/support/vcr_localhost_server.rb +2 -3
- metadata +475 -123
- data/.gemtest +0 -0
- data/.gitignore +0 -52
- data/.gitmodules +0 -3
- data/.rspec +0 -2
- data/.travis.yml +0 -27
- data/.yardopts +0 -9
- data/Appraisals +0 -5
- data/CHANGELOG.md +0 -987
- data/CONTRIBUTING.md +0 -26
- data/Gemfile +0 -54
- data/Gemfile.lock +0 -159
- data/LICENSE +0 -20
- data/README.md +0 -243
- data/Rakefile +0 -197
- data/Upgrade.md +0 -289
- data/benchmarks/http_stubbing_libraries.rb +0 -59
- data/benchmarks/null_logging.rb +0 -62
- data/cucumber.yml +0 -16
- data/features/.nav +0 -62
- data/features/cassettes/persistence.feature +0 -63
- data/features/support/vcr_cucumber_helpers.rb +0 -46
- data/gemfiles/typhoeus_old.gemfile +0 -34
- data/gemfiles/typhoeus_old.gemfile.lock +0 -133
- data/script/ci.sh +0 -27
- data/spec/capture_warnings.rb +0 -73
- data/spec/quality_spec.rb +0 -51
- data/vcr.gemspec +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4220b7228aef7b898a3c0caaac694cde250bf8c2
|
4
|
+
data.tar.gz: 1dc6b739ec86f670219754076cd749edb295c47b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 758f773b6832d30b190aaaba9c24ed7d345c1d31a1216cc8b9ff4bac4175e17f01d9355be38ba2e7bb752c6ab10e8f98c2fa31ddfcac8dbfbe7649d27c279768
|
7
|
+
data.tar.gz: a29dff72f5ed9facdda4038866b2c761905e42ae3c51756406ab965bae03e9b398d3219ebea0963ae85235f84e90492a66e44a61def80412d298ecac56e73c5d
|
@@ -2,7 +2,7 @@ The cucumber features provided here demonstrate all of the major features of
|
|
2
2
|
VCR. These features are executable documentation for VCR.
|
3
3
|
|
4
4
|
Many of the examples use one (or both) of these helper functions
|
5
|
-
provided by `
|
5
|
+
provided by `spec/support/cucumber_helpers.rb`:
|
6
6
|
|
7
7
|
* `start_sinatra_app`: starts a sinatra application on the given port.
|
8
8
|
The server automatically shuts down when the ruby script ends. Many
|
@@ -17,7 +17,7 @@ Feature: Automatic Re-recording
|
|
17
17
|
http_interactions:
|
18
18
|
- request:
|
19
19
|
method: get
|
20
|
-
uri: http://localhost
|
20
|
+
uri: http://localhost/
|
21
21
|
body:
|
22
22
|
encoding: UTF-8
|
23
23
|
string: ""
|
@@ -38,7 +38,7 @@ Feature: Automatic Re-recording
|
|
38
38
|
"""
|
39
39
|
And a file named "re_record.rb" with:
|
40
40
|
"""ruby
|
41
|
-
|
41
|
+
$server = start_sinatra_app do
|
42
42
|
get('/') { 'New Response' }
|
43
43
|
end
|
44
44
|
|
@@ -49,8 +49,8 @@ Feature: Automatic Re-recording
|
|
49
49
|
c.cassette_library_dir = 'cassettes'
|
50
50
|
end
|
51
51
|
|
52
|
-
VCR.use_cassette('example', :re_record_interval => 7.days) do
|
53
|
-
puts Net::HTTP.get_response('localhost', '/',
|
52
|
+
VCR.use_cassette('example', :re_record_interval => 7.days, :match_requests_on => [:method, :host, :path]) do
|
53
|
+
puts Net::HTTP.get_response('localhost', '/', $server.port).body
|
54
54
|
end
|
55
55
|
"""
|
56
56
|
|
@@ -14,7 +14,7 @@ Feature: Decode compressed response
|
|
14
14
|
require 'zlib'
|
15
15
|
require 'stringio'
|
16
16
|
|
17
|
-
|
17
|
+
$server = start_sinatra_app do
|
18
18
|
get('/') {
|
19
19
|
content = 'The quick brown fox jumps over the lazy dog'
|
20
20
|
io = StringIO.new
|
@@ -41,7 +41,7 @@ Feature: Decode compressed response
|
|
41
41
|
When I append to file "decompress.rb":
|
42
42
|
"""ruby
|
43
43
|
VCR.use_cassette(:decompress) do
|
44
|
-
Net::HTTP.start('localhost',
|
44
|
+
Net::HTTP.start('localhost', $server.port) do |http|
|
45
45
|
http.get('/', 'accept-encoding' => 'identity')
|
46
46
|
end
|
47
47
|
end
|
@@ -57,7 +57,7 @@ Feature: Decode compressed response
|
|
57
57
|
When I append to file "decompress.rb":
|
58
58
|
"""ruby
|
59
59
|
VCR.use_cassette(:decompress, :decode_compressed_response => true) do
|
60
|
-
Net::HTTP.start('localhost',
|
60
|
+
Net::HTTP.start('localhost', $server.port) do |http|
|
61
61
|
http.get('/', 'accept-encoding' => 'identity')
|
62
62
|
end
|
63
63
|
end
|
@@ -21,7 +21,7 @@ Feature: exclusive cassette
|
|
21
21
|
http_interactions:
|
22
22
|
- request:
|
23
23
|
method: get
|
24
|
-
uri: http://localhost
|
24
|
+
uri: http://localhost/outer
|
25
25
|
body:
|
26
26
|
encoding: UTF-8
|
27
27
|
string: ""
|
@@ -46,7 +46,7 @@ Feature: exclusive cassette
|
|
46
46
|
http_interactions:
|
47
47
|
- request:
|
48
48
|
method: get
|
49
|
-
uri: http://localhost
|
49
|
+
uri: http://localhost/inner
|
50
50
|
body:
|
51
51
|
encoding: UTF-8
|
52
52
|
string: ""
|
@@ -69,7 +69,7 @@ Feature: exclusive cassette
|
|
69
69
|
"""ruby
|
70
70
|
include_http_adapter_for("net/http")
|
71
71
|
|
72
|
-
|
72
|
+
$server = start_sinatra_app do
|
73
73
|
get('/:path') { "New #{params[:path]} response" }
|
74
74
|
end
|
75
75
|
|
@@ -78,7 +78,10 @@ Feature: exclusive cassette
|
|
78
78
|
VCR.configure do |c|
|
79
79
|
c.hook_into :webmock
|
80
80
|
c.cassette_library_dir = 'cassettes'
|
81
|
-
c.default_cassette_options = {
|
81
|
+
c.default_cassette_options = {
|
82
|
+
:record => :new_episodes,
|
83
|
+
:match_requests_on => [:method, :host, :path]
|
84
|
+
}
|
82
85
|
end
|
83
86
|
"""
|
84
87
|
|
@@ -89,8 +92,8 @@ Feature: exclusive cassette
|
|
89
92
|
|
90
93
|
VCR.use_cassette('outer') do
|
91
94
|
VCR.use_cassette('inner') do
|
92
|
-
puts response_body_for(:get, "http://localhost
|
93
|
-
puts response_body_for(:get, "http://localhost
|
95
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/outer")
|
96
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/inner")
|
94
97
|
end
|
95
98
|
end
|
96
99
|
"""
|
@@ -108,8 +111,8 @@ Feature: exclusive cassette
|
|
108
111
|
|
109
112
|
VCR.use_cassette('outer') do
|
110
113
|
VCR.use_cassette('inner', :exclusive => true) do
|
111
|
-
puts response_body_for(:get, "http://localhost
|
112
|
-
puts response_body_for(:get, "http://localhost
|
114
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/outer")
|
115
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/inner")
|
113
116
|
end
|
114
117
|
end
|
115
118
|
"""
|
@@ -37,6 +37,8 @@ Feature: Cassette format
|
|
37
37
|
you want to ensure that psych is always used.
|
38
38
|
- `:json`--Uses [multi_json](https://github.com/intridea/multi_json)
|
39
39
|
to serialize the cassette data as JSON.
|
40
|
+
- `:compressed`--Wraps the default YAML serializer with Zlib, writing
|
41
|
+
compressed cassettes to disk.
|
40
42
|
|
41
43
|
You can also register a custom serializer using:
|
42
44
|
|
@@ -56,7 +58,7 @@ Feature: Cassette format
|
|
56
58
|
include_http_adapter_for("<http_lib>")
|
57
59
|
|
58
60
|
if ARGV.any?
|
59
|
-
|
61
|
+
$server = start_sinatra_app do
|
60
62
|
get('/:path') { ARGV[0] + ' ' + params[:path] }
|
61
63
|
end
|
62
64
|
end
|
@@ -66,60 +68,63 @@ Feature: Cassette format
|
|
66
68
|
VCR.configure do |c|
|
67
69
|
<configuration>
|
68
70
|
c.cassette_library_dir = 'cassettes'
|
71
|
+
c.before_record do |i|
|
72
|
+
i.request.uri.sub!(/:\d+/, ':7777')
|
73
|
+
end
|
69
74
|
end
|
70
75
|
|
71
76
|
VCR.use_cassette('example') do
|
72
|
-
make_http_request(:get, "http://localhost
|
73
|
-
make_http_request(:get, "http://localhost
|
77
|
+
make_http_request(:get, "http://localhost:#{$server.port}/foo", nil, 'Accept-Encoding' => 'identity')
|
78
|
+
make_http_request(:get, "http://localhost:#{$server.port}/bar", nil, 'Accept-Encoding' => 'identity')
|
74
79
|
end
|
75
80
|
"""
|
76
|
-
When I run `ruby cassette_yaml.rb 'Hello'`
|
81
|
+
When I successfully run `ruby cassette_yaml.rb 'Hello'`
|
77
82
|
Then the file "cassettes/example.yml" should contain YAML like:
|
78
83
|
"""
|
79
|
-
---
|
80
|
-
http_interactions:
|
81
|
-
- request:
|
84
|
+
---
|
85
|
+
http_interactions:
|
86
|
+
- request:
|
82
87
|
method: get
|
83
88
|
uri: http://localhost:7777/foo
|
84
|
-
body:
|
89
|
+
body:
|
85
90
|
encoding: UTF-8
|
86
91
|
string: ""
|
87
|
-
headers:
|
88
|
-
Accept-Encoding:
|
92
|
+
headers:
|
93
|
+
Accept-Encoding:
|
89
94
|
- identity
|
90
|
-
response:
|
91
|
-
status:
|
95
|
+
response:
|
96
|
+
status:
|
92
97
|
code: 200
|
93
98
|
message: OK
|
94
|
-
headers:
|
95
|
-
Content-Type:
|
99
|
+
headers:
|
100
|
+
Content-Type:
|
96
101
|
- text/html;charset=utf-8
|
97
|
-
Content-Length:
|
102
|
+
Content-Length:
|
98
103
|
- "9"
|
99
|
-
body:
|
104
|
+
body:
|
100
105
|
encoding: UTF-8
|
101
106
|
string: Hello foo
|
102
107
|
http_version: "1.1"
|
103
108
|
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
104
|
-
- request:
|
109
|
+
- request:
|
105
110
|
method: get
|
106
111
|
uri: http://localhost:7777/bar
|
107
|
-
body:
|
112
|
+
body:
|
108
113
|
encoding: UTF-8
|
109
114
|
string: ""
|
110
|
-
headers:
|
111
|
-
Accept-Encoding:
|
115
|
+
headers:
|
116
|
+
Accept-Encoding:
|
112
117
|
- identity
|
113
|
-
response:
|
114
|
-
status:
|
118
|
+
response:
|
119
|
+
status:
|
115
120
|
code: 200
|
116
121
|
message: OK
|
117
|
-
headers:
|
118
|
-
Content-Type:
|
122
|
+
headers:
|
123
|
+
Content-Type:
|
119
124
|
- text/html;charset=utf-8
|
120
|
-
Content-Length:
|
125
|
+
Content-Length:
|
121
126
|
- "9"
|
122
|
-
body:
|
127
|
+
body:
|
123
128
|
encoding: UTF-8
|
124
129
|
string: Hello bar
|
125
130
|
http_version: "1.1"
|
@@ -145,7 +150,7 @@ Feature: Cassette format
|
|
145
150
|
"""ruby
|
146
151
|
include_http_adapter_for("net/http")
|
147
152
|
|
148
|
-
|
153
|
+
$server = start_sinatra_app do
|
149
154
|
get('/:path') { ARGV[0] + ' ' + params[:path] }
|
150
155
|
end
|
151
156
|
|
@@ -154,11 +159,17 @@ Feature: Cassette format
|
|
154
159
|
VCR.configure do |c|
|
155
160
|
c.hook_into :webmock
|
156
161
|
c.cassette_library_dir = 'cassettes'
|
162
|
+
c.before_record do |i|
|
163
|
+
i.request.uri.sub!(/:\d+/, ':7777')
|
164
|
+
end
|
165
|
+
c.default_cassette_options = {
|
166
|
+
:match_requests_on => [:method, :host, :path]
|
167
|
+
}
|
157
168
|
end
|
158
169
|
|
159
170
|
VCR.use_cassette('example', :serialize_with => :json) do
|
160
|
-
puts response_body_for(:get, "http://localhost
|
161
|
-
puts response_body_for(:get, "http://localhost
|
171
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/foo", nil, 'Accept-Encoding' => 'identity')
|
172
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/bar", nil, 'Accept-Encoding' => 'identity')
|
162
173
|
end
|
163
174
|
"""
|
164
175
|
When I run `ruby cassette_json.rb 'Hello'`
|
@@ -235,12 +246,98 @@ Feature: Cassette format
|
|
235
246
|
Hello bar
|
236
247
|
"""
|
237
248
|
|
249
|
+
Scenario: Request/Response data can be saved as compressed YAML
|
250
|
+
Given a file named "cassette_compressed.rb" with:
|
251
|
+
"""ruby
|
252
|
+
include_http_adapter_for("net/http")
|
253
|
+
|
254
|
+
$server = start_sinatra_app do
|
255
|
+
get('/:path') { ARGV[0] + ' ' + params[:path] }
|
256
|
+
end
|
257
|
+
|
258
|
+
require 'vcr'
|
259
|
+
|
260
|
+
VCR.configure do |c|
|
261
|
+
c.hook_into :webmock
|
262
|
+
c.cassette_library_dir = 'cassettes'
|
263
|
+
c.before_record do |i|
|
264
|
+
i.request.uri.sub!(/:\d+/, ':7777')
|
265
|
+
end
|
266
|
+
c.default_cassette_options = {
|
267
|
+
:match_requests_on => [:method, :host, :path]
|
268
|
+
}
|
269
|
+
end
|
270
|
+
|
271
|
+
VCR.use_cassette('example', :serialize_with => :compressed) do
|
272
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/foo", nil, 'Accept-Encoding' => 'identity')
|
273
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/bar", nil, 'Accept-Encoding' => 'identity')
|
274
|
+
end
|
275
|
+
|
276
|
+
"""
|
277
|
+
When I run `ruby cassette_compressed.rb 'Hello'`
|
278
|
+
Then the file "cassettes/example.gz" should contain compressed YAML like:
|
279
|
+
"""
|
280
|
+
---
|
281
|
+
http_interactions:
|
282
|
+
- request:
|
283
|
+
method: get
|
284
|
+
uri: http://localhost:7777/foo
|
285
|
+
body:
|
286
|
+
encoding: UTF-8
|
287
|
+
string: ""
|
288
|
+
headers:
|
289
|
+
Accept-Encoding:
|
290
|
+
- identity
|
291
|
+
response:
|
292
|
+
status:
|
293
|
+
code: 200
|
294
|
+
message: OK
|
295
|
+
headers:
|
296
|
+
Content-Type:
|
297
|
+
- text/html;charset=utf-8
|
298
|
+
Content-Length:
|
299
|
+
- "9"
|
300
|
+
body:
|
301
|
+
encoding: UTF-8
|
302
|
+
string: Hello foo
|
303
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
304
|
+
- request:
|
305
|
+
method: get
|
306
|
+
uri: http://localhost:7777/bar
|
307
|
+
body:
|
308
|
+
encoding: UTF-8
|
309
|
+
string: ""
|
310
|
+
headers:
|
311
|
+
Accept-Encoding:
|
312
|
+
- identity
|
313
|
+
response:
|
314
|
+
status:
|
315
|
+
code: 200
|
316
|
+
message: OK
|
317
|
+
headers:
|
318
|
+
Content-Type:
|
319
|
+
- text/html;charset=utf-8
|
320
|
+
Content-Length:
|
321
|
+
- "9"
|
322
|
+
body:
|
323
|
+
encoding: UTF-8
|
324
|
+
string: Hello bar
|
325
|
+
recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
|
326
|
+
recorded_with: VCR 2.0.0
|
327
|
+
"""
|
328
|
+
When I run `ruby cassette_compressed.rb`
|
329
|
+
Then it should pass with:
|
330
|
+
"""
|
331
|
+
Hello foo
|
332
|
+
Hello bar
|
333
|
+
"""
|
334
|
+
|
238
335
|
Scenario: Request/Response data can be saved using a custom serializer
|
239
336
|
Given a file named "cassette_ruby.rb" with:
|
240
337
|
"""ruby
|
241
338
|
include_http_adapter_for("net/http")
|
242
339
|
|
243
|
-
|
340
|
+
$server = start_sinatra_app do
|
244
341
|
get('/:path') { ARGV[0] + ' ' + params[:path] }
|
245
342
|
end
|
246
343
|
|
@@ -259,11 +356,17 @@ Feature: Cassette format
|
|
259
356
|
c.hook_into :webmock
|
260
357
|
c.cassette_library_dir = 'cassettes'
|
261
358
|
c.cassette_serializers[:ruby] = ruby_serializer
|
359
|
+
c.before_record do |i|
|
360
|
+
i.request.uri.sub!(/:\d+/, ':7777')
|
361
|
+
end
|
362
|
+
c.default_cassette_options = {
|
363
|
+
:match_requests_on => [:method, :host, :path]
|
364
|
+
}
|
262
365
|
end
|
263
366
|
|
264
367
|
VCR.use_cassette('example', :serialize_with => :ruby) do
|
265
|
-
puts response_body_for(:get, "http://localhost
|
266
|
-
puts response_body_for(:get, "http://localhost
|
368
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/foo", nil, 'Accept-Encoding' => 'identity')
|
369
|
+
puts response_body_for(:get, "http://localhost:#{$server.port}/bar", nil, 'Accept-Encoding' => 'identity')
|
267
370
|
end
|
268
371
|
"""
|
269
372
|
When I run `ruby cassette_ruby.rb 'Hello'`
|
@@ -8,7 +8,7 @@ Feature: Naming
|
|
8
8
|
Scenario: Name sanitizing
|
9
9
|
Given a file named "name_sanitizing.rb" with:
|
10
10
|
"""ruby
|
11
|
-
|
11
|
+
$server = start_sinatra_app do
|
12
12
|
get('/') { "Hello" }
|
13
13
|
end
|
14
14
|
|
@@ -20,7 +20,7 @@ Feature: Naming
|
|
20
20
|
end
|
21
21
|
|
22
22
|
VCR.use_cassette('Fee, Fi Fo Fum') do
|
23
|
-
Net::HTTP.get_response('localhost', '/',
|
23
|
+
Net::HTTP.get_response('localhost', '/', $server.port)
|
24
24
|
end
|
25
25
|
"""
|
26
26
|
And the directory "cassettes" does not exist
|
@@ -56,7 +56,7 @@ Feature: Error for HTTP request made when no cassette is in use
|
|
56
56
|
Scenario: Temporarily turn VCR off to allow HTTP requests to procede as normal
|
57
57
|
Given a file named "turn_off_vcr.rb" with:
|
58
58
|
"""ruby
|
59
|
-
|
59
|
+
$server = start_sinatra_app do
|
60
60
|
get('/') { 'Hello' }
|
61
61
|
end
|
62
62
|
|
@@ -69,7 +69,7 @@ Feature: Error for HTTP request made when no cassette is in use
|
|
69
69
|
|
70
70
|
def make_request(context)
|
71
71
|
puts context
|
72
|
-
puts Net::HTTP.get_response('localhost', '/',
|
72
|
+
puts Net::HTTP.get_response('localhost', '/', $server.port).body
|
73
73
|
rescue => e
|
74
74
|
puts "Error: #{e.class}"
|
75
75
|
end
|
@@ -127,7 +127,7 @@ Feature: Error for HTTP request made when no cassette is in use
|
|
127
127
|
Scenario: Turning VCR off with `:ignore_cassettes => true` ignores cassettes
|
128
128
|
Given a file named "turn_off_vcr_and_insert_cassette.rb" with:
|
129
129
|
"""ruby
|
130
|
-
|
130
|
+
$server = start_sinatra_app do
|
131
131
|
get('/') { 'Hello' }
|
132
132
|
end
|
133
133
|
|
@@ -142,7 +142,7 @@ Feature: Error for HTTP request made when no cassette is in use
|
|
142
142
|
VCR.turn_off!(:ignore_cassettes => true)
|
143
143
|
|
144
144
|
VCR.use_cassette('example') do
|
145
|
-
response = Net::HTTP.get_response('localhost', '/',
|
145
|
+
response = Net::HTTP.get_response('localhost', '/', $server.port).body
|
146
146
|
puts "Response: #{response}"
|
147
147
|
end
|
148
148
|
"""
|
@@ -9,7 +9,7 @@ Feature: Allow HTTP connections when no cassette
|
|
9
9
|
Given a file named "vcr_setup.rb" with:
|
10
10
|
"""ruby
|
11
11
|
if ARGV.include?('--with-server')
|
12
|
-
|
12
|
+
$server = start_sinatra_app do
|
13
13
|
get('/') { "Hello" }
|
14
14
|
end
|
15
15
|
end
|
@@ -20,6 +20,9 @@ Feature: Allow HTTP connections when no cassette
|
|
20
20
|
c.allow_http_connections_when_no_cassette = true
|
21
21
|
c.hook_into :webmock
|
22
22
|
c.cassette_library_dir = 'cassettes'
|
23
|
+
c.default_cassette_options = {
|
24
|
+
:match_requests_on => [:method, :host, :path]
|
25
|
+
}
|
23
26
|
end
|
24
27
|
"""
|
25
28
|
And the directory "vcr/cassettes" does not exist
|
@@ -29,7 +32,7 @@ Feature: Allow HTTP connections when no cassette
|
|
29
32
|
"""ruby
|
30
33
|
require 'vcr_setup.rb'
|
31
34
|
|
32
|
-
puts "Response: " + Net::HTTP.get_response('localhost', '/',
|
35
|
+
puts "Response: " + Net::HTTP.get_response('localhost', '/', $server ? $server.port : 0).body
|
33
36
|
"""
|
34
37
|
When I run `ruby no_cassette.rb --with-server`
|
35
38
|
Then the output should contain "Response: Hello"
|
@@ -40,7 +43,7 @@ Feature: Allow HTTP connections when no cassette
|
|
40
43
|
require 'vcr_setup.rb'
|
41
44
|
|
42
45
|
VCR.use_cassette('localhost') do
|
43
|
-
puts "Response: " + Net::HTTP.get_response('localhost', '/',
|
46
|
+
puts "Response: " + Net::HTTP.get_response('localhost', '/', $server ? $server.port : 0).body
|
44
47
|
end
|
45
48
|
"""
|
46
49
|
When I run `ruby record_replay_cassette.rb --with-server`
|