vcr 3.0.3 → 6.2.0

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.
Files changed (146) hide show
  1. checksums.yaml +5 -5
  2. data/lib/vcr/cassette/erb_renderer.rb +4 -2
  3. data/lib/vcr/cassette/http_interaction_list.rb +14 -9
  4. data/lib/vcr/cassette/migrator.rb +5 -6
  5. data/lib/vcr/cassette/persisters/file_system.rb +9 -1
  6. data/lib/vcr/cassette/serializers/compressed.rb +2 -2
  7. data/lib/vcr/cassette/serializers/json.rb +14 -8
  8. data/lib/vcr/cassette/serializers/psych.rb +10 -2
  9. data/lib/vcr/cassette/serializers/syck.rb +7 -1
  10. data/lib/vcr/cassette/serializers/yaml.rb +14 -2
  11. data/lib/vcr/cassette/serializers.rb +10 -0
  12. data/lib/vcr/cassette.rb +63 -16
  13. data/lib/vcr/configuration.rb +21 -8
  14. data/lib/vcr/deprecations.rb +0 -62
  15. data/lib/vcr/errors.rb +17 -12
  16. data/lib/vcr/library_hooks/excon.rb +8 -0
  17. data/lib/vcr/library_hooks/typhoeus.rb +91 -79
  18. data/lib/vcr/library_hooks/webmock.rb +2 -11
  19. data/lib/vcr/linked_cassette.rb +4 -4
  20. data/lib/vcr/middleware/excon.rb +1 -1
  21. data/lib/vcr/middleware/faraday.rb +29 -2
  22. data/lib/vcr/request_ignorer.rb +8 -1
  23. data/lib/vcr/request_matcher_registry.rb +3 -3
  24. data/lib/vcr/structs.rb +48 -32
  25. data/lib/vcr/test_frameworks/cucumber.rb +16 -5
  26. data/lib/vcr/test_frameworks/rspec.rb +34 -22
  27. data/lib/vcr/util/hooks.rb +1 -0
  28. data/lib/vcr/util/internet_connection.rb +15 -21
  29. data/lib/vcr/version.rb +2 -2
  30. data/lib/vcr.rb +52 -2
  31. metadata +45 -272
  32. data/features/CHANGELOG.md +0 -710
  33. data/features/CONTRIBUTING.md +0 -26
  34. data/features/LICENSE.md +0 -20
  35. data/features/README.md +0 -339
  36. data/features/Upgrade.md +0 -289
  37. data/features/about_these_examples.md +0 -18
  38. data/features/cassettes/allow_unused_http_interactions.feature +0 -100
  39. data/features/cassettes/automatic_re_recording.feature +0 -72
  40. data/features/cassettes/decompress.feature +0 -74
  41. data/features/cassettes/dynamic_erb.feature +0 -100
  42. data/features/cassettes/exclusive.feature +0 -126
  43. data/features/cassettes/format.feature +0 -411
  44. data/features/cassettes/freezing_time.feature +0 -68
  45. data/features/cassettes/naming.feature +0 -28
  46. data/features/cassettes/no_cassette.feature +0 -152
  47. data/features/cassettes/update_content_length_header.feature +0 -112
  48. data/features/configuration/allow_http_connections_when_no_cassette.feature +0 -55
  49. data/features/configuration/cassette_library_dir.feature +0 -31
  50. data/features/configuration/debug_logging.feature +0 -58
  51. data/features/configuration/default_cassette_options.feature +0 -100
  52. data/features/configuration/filter_sensitive_data.feature +0 -153
  53. data/features/configuration/hook_into.feature +0 -172
  54. data/features/configuration/ignore_request.feature +0 -192
  55. data/features/configuration/preserve_exact_body_bytes.feature +0 -108
  56. data/features/configuration/query_parser.feature +0 -84
  57. data/features/configuration/uri_parser.feature +0 -93
  58. data/features/getting_started.md +0 -82
  59. data/features/hooks/after_http_request.feature +0 -58
  60. data/features/hooks/around_http_request.feature +0 -57
  61. data/features/hooks/before_http_request.feature +0 -63
  62. data/features/hooks/before_playback.feature +0 -184
  63. data/features/hooks/before_record.feature +0 -172
  64. data/features/http_libraries/em_http_request.feature +0 -250
  65. data/features/http_libraries/net_http.feature +0 -179
  66. data/features/middleware/faraday.feature +0 -56
  67. data/features/middleware/rack.feature +0 -92
  68. data/features/record_modes/all.feature +0 -82
  69. data/features/record_modes/new_episodes.feature +0 -79
  70. data/features/record_modes/none.feature +0 -72
  71. data/features/record_modes/once.feature +0 -95
  72. data/features/request_matching/README.md +0 -30
  73. data/features/request_matching/body.feature +0 -91
  74. data/features/request_matching/body_as_json.feature +0 -90
  75. data/features/request_matching/custom_matcher.feature +0 -135
  76. data/features/request_matching/headers.feature +0 -85
  77. data/features/request_matching/host.feature +0 -95
  78. data/features/request_matching/identical_request_sequence.feature +0 -89
  79. data/features/request_matching/method.feature +0 -96
  80. data/features/request_matching/path.feature +0 -96
  81. data/features/request_matching/playback_repeats.feature +0 -98
  82. data/features/request_matching/query.feature +0 -97
  83. data/features/request_matching/uri.feature +0 -94
  84. data/features/request_matching/uri_without_param.feature +0 -101
  85. data/features/step_definitions/cli_steps.rb +0 -199
  86. data/features/support/env.rb +0 -46
  87. data/features/support/http_lib_filters.rb +0 -46
  88. data/features/test_frameworks/cucumber.feature +0 -211
  89. data/features/test_frameworks/rspec_macro.feature +0 -81
  90. data/features/test_frameworks/rspec_metadata.feature +0 -150
  91. data/features/test_frameworks/test_unit.feature +0 -49
  92. data/lib/vcr/extensions/net_http_response.rb +0 -36
  93. data/lib/vcr/library_hooks/fakeweb.rb +0 -197
  94. data/lib/vcr/library_hooks/typhoeus_0.4.rb +0 -103
  95. data/spec/acceptance/concurrency_spec.rb +0 -51
  96. data/spec/acceptance/threading_spec.rb +0 -34
  97. data/spec/fixtures/cassette_spec/1_x_cassette.yml +0 -110
  98. data/spec/fixtures/cassette_spec/empty.yml +0 -0
  99. data/spec/fixtures/cassette_spec/example.yml +0 -111
  100. data/spec/fixtures/cassette_spec/with_localhost_requests.yml +0 -111
  101. data/spec/fixtures/fake_example_responses.yml +0 -110
  102. data/spec/fixtures/match_requests_on.yml +0 -187
  103. data/spec/lib/vcr/cassette/erb_renderer_spec.rb +0 -53
  104. data/spec/lib/vcr/cassette/http_interaction_list_spec.rb +0 -295
  105. data/spec/lib/vcr/cassette/migrator_spec.rb +0 -196
  106. data/spec/lib/vcr/cassette/persisters/file_system_spec.rb +0 -75
  107. data/spec/lib/vcr/cassette/persisters_spec.rb +0 -39
  108. data/spec/lib/vcr/cassette/serializers_spec.rb +0 -182
  109. data/spec/lib/vcr/cassette_spec.rb +0 -618
  110. data/spec/lib/vcr/configuration_spec.rb +0 -326
  111. data/spec/lib/vcr/deprecations_spec.rb +0 -85
  112. data/spec/lib/vcr/errors_spec.rb +0 -178
  113. data/spec/lib/vcr/extensions/net_http_response_spec.rb +0 -86
  114. data/spec/lib/vcr/library_hooks/excon_spec.rb +0 -104
  115. data/spec/lib/vcr/library_hooks/fakeweb_spec.rb +0 -169
  116. data/spec/lib/vcr/library_hooks/faraday_spec.rb +0 -68
  117. data/spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb +0 -36
  118. data/spec/lib/vcr/library_hooks/typhoeus_spec.rb +0 -162
  119. data/spec/lib/vcr/library_hooks/webmock_spec.rb +0 -117
  120. data/spec/lib/vcr/library_hooks_spec.rb +0 -51
  121. data/spec/lib/vcr/middleware/faraday_spec.rb +0 -181
  122. data/spec/lib/vcr/middleware/rack_spec.rb +0 -115
  123. data/spec/lib/vcr/request_ignorer_spec.rb +0 -70
  124. data/spec/lib/vcr/request_matcher_registry_spec.rb +0 -345
  125. data/spec/lib/vcr/structs_spec.rb +0 -732
  126. data/spec/lib/vcr/test_frameworks/cucumber_spec.rb +0 -107
  127. data/spec/lib/vcr/test_frameworks/rspec_spec.rb +0 -94
  128. data/spec/lib/vcr/util/hooks_spec.rb +0 -158
  129. data/spec/lib/vcr/util/internet_connection_spec.rb +0 -37
  130. data/spec/lib/vcr/util/version_checker_spec.rb +0 -31
  131. data/spec/lib/vcr/version_spec.rb +0 -27
  132. data/spec/lib/vcr_spec.rb +0 -354
  133. data/spec/monkey_patches.rb +0 -186
  134. data/spec/spec_helper.rb +0 -63
  135. data/spec/support/configuration_stubbing.rb +0 -8
  136. data/spec/support/cucumber_helpers.rb +0 -39
  137. data/spec/support/fixnum_extension.rb +0 -10
  138. data/spec/support/http_library_adapters.rb +0 -289
  139. data/spec/support/limited_uri.rb +0 -21
  140. data/spec/support/ruby_interpreter.rb +0 -7
  141. data/spec/support/shared_example_groups/excon.rb +0 -63
  142. data/spec/support/shared_example_groups/hook_into_http_library.rb +0 -594
  143. data/spec/support/shared_example_groups/request_hooks.rb +0 -59
  144. data/spec/support/sinatra_app.rb +0 -86
  145. data/spec/support/vcr_localhost_server.rb +0 -76
  146. data/spec/support/vcr_stub_helpers.rb +0 -17
@@ -1,345 +0,0 @@
1
- require 'vcr/request_matcher_registry'
2
- require 'vcr/structs'
3
- require 'support/limited_uri'
4
- require 'cgi'
5
- require 'support/configuration_stubbing'
6
-
7
- module VCR
8
- describe RequestMatcherRegistry do
9
- include_context "configuration stubbing"
10
-
11
- before do
12
- allow(config).to receive(:uri_parser) { LimitedURI }
13
- allow(config).to receive(:query_parser) { CGI.method(:parse) }
14
- end
15
-
16
- def request_with(values)
17
- VCR::Request.new.tap do |request|
18
- values.each do |name, value|
19
- request.send("#{name}=", value)
20
- end
21
- end
22
- end
23
-
24
- describe "#register" do
25
- it 'registers a request matcher block that can be used later' do
26
- matcher_called = false
27
- subject.register(:my_matcher) { |*a| matcher_called = true }
28
- subject[:my_matcher].matches?(double, double)
29
- expect(matcher_called).to be true
30
- end
31
-
32
- context 'when there is already a matcher for the given name' do
33
- before(:each) do
34
- subject.register(:foo) { |*a| false }
35
- allow(subject).to receive :warn
36
- end
37
-
38
- it 'overrides the existing matcher' do
39
- subject.register(:foo) { |*a| true }
40
- expect(subject[:foo].matches?(double, double)).to be true
41
- end
42
-
43
- it 'warns that there is a name collision' do
44
- expect(subject).to receive(:warn).with(
45
- /WARNING: There is already a VCR request matcher registered for :foo\. Overriding it/
46
- )
47
-
48
- subject.register(:foo) { |*a| true }
49
- end
50
- end
51
- end
52
-
53
- describe "#[]" do
54
- it 'returns a previously registered matcher' do
55
- matcher = lambda { }
56
- subject.register(:my_matcher, &matcher)
57
- expect(subject[:my_matcher]).to eq(RequestMatcherRegistry::Matcher.new(matcher))
58
- end
59
-
60
- it 'raises an ArgumentError when no matcher has been registered for the given name' do
61
- expect {
62
- subject[:some_unregistered_matcher]
63
- }.to raise_error(VCR::Errors::UnregisteredMatcherError)
64
- end
65
-
66
- it 'returns an object that calls the named block when #matches? is called on it' do
67
- subject.register(:foo) { |r1, r2| r1 == 5 || r2 == 10 }
68
- expect(subject[:foo].matches?(5, 0)).to be true
69
- expect(subject[:foo].matches?(0, 10)).to be true
70
- expect(subject[:foo].matches?(7, 7)).to be false
71
- end
72
-
73
- it 'returns an object that calls the given callable when #matches? is called on it' do
74
- block_called = false
75
- subject[lambda { |r1, r2| block_called = true }].matches?(5, 0)
76
- expect(block_called).to be true
77
- end
78
- end
79
-
80
- [:uri_without_param, :uri_without_params].each do |meth|
81
- describe "##{meth}" do
82
- it 'returns a matcher that can be registered for later use' do
83
- matcher = subject.send(meth, :foo)
84
- subject.register(:uri_without_foo, &matcher)
85
- matches = subject[:uri_without_foo].matches?(
86
- request_with(:uri => 'http://example.com/search?foo=123'),
87
- request_with(:uri => 'http://example.com/search?foo=123')
88
- )
89
- expect(matches).to be true
90
- end
91
-
92
- it 'matches two requests with URIs that are identical' do
93
- matches = subject[subject.send(meth, :foo)].matches?(
94
- request_with(:uri => 'http://example.com/search?foo=123'),
95
- request_with(:uri => 'http://example.com/search?foo=123')
96
- )
97
- expect(matches).to be true
98
- end
99
-
100
- it 'does not match two requests with different path parts' do
101
- matches = subject[subject.send(meth, :foo)].matches?(
102
- request_with(:uri => 'http://example.com/search?foo=123'),
103
- request_with(:uri => 'http://example.com/find?foo=123')
104
- )
105
- expect(matches).to be false
106
- end
107
-
108
- it 'ignores the given query parameters when it is at the start' do
109
- matches = subject[subject.send(meth, :foo)].matches?(
110
- request_with(:uri => 'http://example.com/search?foo=123&bar=r'),
111
- request_with(:uri => 'http://example.com/search?foo=124&bar=r')
112
- )
113
- expect(matches).to be true
114
- end
115
-
116
- it 'ignores the given query parameters when it is at the end' do
117
- matches = subject[subject.send(meth, :bar)].matches?(
118
- request_with(:uri => 'http://example.com/search?foo=124&bar=r'),
119
- request_with(:uri => 'http://example.com/search?foo=124&bar=q')
120
- )
121
- expect(matches).to be true
122
- end
123
-
124
- it 'still takes into account other query params' do
125
- matches = subject[subject.send(meth, :bar)].matches?(
126
- request_with(:uri => 'http://example.com/search?foo=123&bar=r'),
127
- request_with(:uri => 'http://example.com/search?foo=124&bar=q')
128
- )
129
- expect(matches).to be false
130
- end
131
-
132
- it 'handles multiple query params of the same name' do
133
- matches = subject[subject.send(meth, :tag)].matches?(
134
- request_with(:uri => 'http://example.com/search?foo=124&tag[]=a&tag[]=b'),
135
- request_with(:uri => 'http://example.com/search?foo=124&tag[]=d&tag[]=e')
136
- )
137
- expect(matches).to be true
138
- end
139
-
140
- it 'can ignore multiple named parameters' do
141
- matches = subject[subject.send(meth, :foo, :bar)].matches?(
142
- request_with(:uri => 'http://example.com/search?foo=123&bar=r&baz=9'),
143
- request_with(:uri => 'http://example.com/search?foo=124&baz=9&bar=q')
144
- )
145
- expect(matches).to be true
146
- end
147
-
148
- it 'matches two requests with URIs that have no params' do
149
- matches = subject[subject.send(meth, :foo, :bar)].matches?(
150
- request_with(:uri => 'http://example.com/search'),
151
- request_with(:uri => 'http://example.com/search')
152
- )
153
- expect(matches).to be true
154
- end
155
-
156
- it 'does not match two requests with URIs that have no params but different paths' do
157
- matches = subject[subject.send(meth, :foo, :bar)].matches?(
158
- request_with(:uri => 'http://example.com/foo'),
159
- request_with(:uri => 'http://example.com/bar')
160
- )
161
- expect(matches).to be false
162
- end
163
-
164
- it 'matches a second request when all parameters are filtered' do
165
- matches = subject[subject.send(meth, :q, :oq)].matches?(
166
- request_with(:uri => 'http://example.com/search'),
167
- request_with(:uri => 'http://example.com/search?q=vcr&oq=vcr')
168
- )
169
- expect(matches).to be true
170
- end
171
- end
172
- end
173
-
174
- describe "built-ins" do
175
- describe ":method" do
176
- it 'matches when it is the same' do
177
- matches = subject[:method].matches?(
178
- request_with(:method => :get),
179
- request_with(:method => :get)
180
- )
181
- expect(matches).to be true
182
- end
183
-
184
- it 'does not match when it is not the same' do
185
- matches = subject[:method].matches?(
186
- request_with(:method => :get),
187
- request_with(:method => :post)
188
- )
189
- expect(matches).to be false
190
- end
191
- end
192
-
193
- describe ":uri" do
194
- it 'matches when it is exactly the same' do
195
- matches = subject[:uri].matches?(
196
- request_with(:uri => 'http://foo.com/bar?baz=7'),
197
- request_with(:uri => 'http://foo.com/bar?baz=7')
198
- )
199
- expect(matches).to be true
200
- end
201
-
202
- it 'does not match when it is different' do
203
- matches = subject[:uri].matches?(
204
- request_with(:uri => 'http://foo1.com/bar?baz=7'),
205
- request_with(:uri => 'http://foo2.com/bar?baz=7')
206
- )
207
- expect(matches).to be false
208
- end
209
- end
210
-
211
- describe ":host" do
212
- it 'matches when it is the same' do
213
- matches = subject[:host].matches?(
214
- request_with(:uri => 'http://foo.com/bar'),
215
- request_with(:uri => 'http://foo.com/car')
216
- )
217
- expect(matches).to be true
218
- end
219
-
220
- it 'does not match when it is not the same' do
221
- matches = subject[:host].matches?(
222
- request_with(:uri => 'http://foo.com/bar'),
223
- request_with(:uri => 'http://goo.com/bar')
224
- )
225
- expect(matches).to be false
226
- end
227
- end
228
-
229
- describe ":path" do
230
- it 'matches when it is the same' do
231
- matches = subject[:path].matches?(
232
- request_with(:uri => 'http://foo.com/bar?a=8'),
233
- request_with(:uri => 'http://goo.com/bar?a=9')
234
- )
235
- expect(matches).to be true
236
- end
237
-
238
- it 'does not match when it is not the same' do
239
- matches = subject[:path].matches?(
240
- request_with(:uri => 'http://foo.com/bar?a=8'),
241
- request_with(:uri => 'http://foo.com/car?a=8')
242
- )
243
- expect(matches).to be false
244
- end
245
- end
246
-
247
- describe ":body" do
248
- it 'matches when it is the same' do
249
- matches = subject[:body].matches?(
250
- request_with(:body => 'foo'),
251
- request_with(:body => 'foo')
252
- )
253
- expect(matches).to be true
254
- end
255
-
256
- it 'does not match when it is not the same' do
257
- matches = subject[:body].matches?(
258
- request_with(:body => 'foo'),
259
- request_with(:body => 'bar')
260
- )
261
- expect(matches).to be false
262
- end
263
- end
264
-
265
- describe ":body_as_json" do
266
- it 'matches when the body json is reordered' do
267
- matches = subject[:body_as_json].matches?(
268
- request_with(:body => '{ "a": "1", "b": "2" }'),
269
- request_with(:body => '{ "b": "2", "a": "1" }')
270
- )
271
- expect(matches).to be true
272
- end
273
-
274
- it 'does not match when json is not the same' do
275
- matches = subject[:body_as_json].matches?(
276
- request_with(:body => '{ "a": "1", "b": "2" }'),
277
- request_with(:body => '{ "a": "1", "b": "1" }')
278
- )
279
- expect(matches).to be false
280
- end
281
-
282
- it 'does not match when body is not json' do
283
- matches = subject[:body_as_json].matches?(
284
- request_with(:body => 'a=b'),
285
- request_with(:body => 'a=b')
286
- )
287
- expect(matches).to be false
288
- end
289
- end
290
-
291
- describe ":headers" do
292
- it 'matches when it is the same' do
293
- matches = subject[:headers].matches?(
294
- request_with(:headers => { 'a' => 1, 'b' => 2 }),
295
- request_with(:headers => { 'b' => 2, 'a' => 1 })
296
- )
297
- expect(matches).to be true
298
- end
299
-
300
- it 'does not match when it is not the same' do
301
- matches = subject[:headers].matches?(
302
- request_with(:headers => { 'a' => 3, 'b' => 2 }),
303
- request_with(:headers => { 'b' => 2, 'a' => 1 })
304
- )
305
- expect(matches).to be false
306
- end
307
- end
308
-
309
- describe ":query" do
310
- it 'matches when it is identical' do
311
- matches = subject[:query].matches?(
312
- request_with(:uri => 'http://foo.com/bar?a=8'),
313
- request_with(:uri => 'http://goo.com/car?a=8')
314
- )
315
- expect(matches).to be true
316
- end
317
-
318
- it 'matches when empty' do
319
- matches = subject[:query].matches?(
320
- request_with(:uri => 'http://foo.com/bar'),
321
- request_with(:uri => 'http://goo.com/car')
322
- )
323
- expect(matches).to be true
324
- end
325
-
326
- it 'matches when parameters are reordered' do
327
- matches = subject[:query].matches?(
328
- request_with(:uri => 'http://foo.com/bar?a=8&b=9'),
329
- request_with(:uri => 'http://goo.com/car?b=9&a=8')
330
- )
331
- expect(matches).to be true
332
- end
333
-
334
- it 'does not match when it is not the same' do
335
- matches = subject[:query].matches?(
336
- request_with(:uri => 'http://foo.com/bar?a=8'),
337
- request_with(:uri => 'http://goo.com/car?b=8')
338
- )
339
- expect(matches).to be false
340
- end
341
- end
342
- end
343
- end
344
- end
345
-