vcr 2.0.0.beta1 → 2.0.0.beta2

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 (88) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +3 -0
  3. data/CHANGELOG.md +37 -2
  4. data/Gemfile +2 -2
  5. data/README.md +10 -1
  6. data/Rakefile +43 -7
  7. data/Upgrade.md +45 -0
  8. data/features/.nav +1 -0
  9. data/features/cassettes/automatic_re_recording.feature +19 -17
  10. data/features/cassettes/dynamic_erb.feature +32 -28
  11. data/features/cassettes/exclusive.feature +28 -24
  12. data/features/cassettes/format.feature +213 -31
  13. data/features/cassettes/update_content_length_header.feature +20 -18
  14. data/features/configuration/filter_sensitive_data.feature +4 -4
  15. data/features/configuration/hooks.feature +27 -23
  16. data/features/http_libraries/em_http_request.feature +79 -75
  17. data/features/record_modes/all.feature +14 -14
  18. data/features/record_modes/new_episodes.feature +15 -15
  19. data/features/record_modes/none.feature +15 -15
  20. data/features/record_modes/once.feature +15 -15
  21. data/features/request_matching/body.feature +25 -23
  22. data/features/request_matching/custom_matcher.feature +25 -23
  23. data/features/request_matching/headers.feature +32 -36
  24. data/features/request_matching/host.feature +27 -25
  25. data/features/request_matching/identical_request_sequence.feature +27 -25
  26. data/features/request_matching/method.feature +27 -25
  27. data/features/request_matching/path.feature +27 -25
  28. data/features/request_matching/playback_repeats.feature +27 -25
  29. data/features/request_matching/uri.feature +27 -25
  30. data/features/request_matching/uri_without_param.feature +28 -26
  31. data/features/step_definitions/cli_steps.rb +71 -17
  32. data/features/support/env.rb +3 -1
  33. data/features/support/http_lib_filters.rb +6 -3
  34. data/features/support/vcr_cucumber_helpers.rb +4 -2
  35. data/lib/vcr.rb +6 -2
  36. data/lib/vcr/cassette.rb +75 -51
  37. data/lib/vcr/cassette/migrator.rb +111 -0
  38. data/lib/vcr/cassette/serializers.rb +35 -0
  39. data/lib/vcr/cassette/serializers/json.rb +23 -0
  40. data/lib/vcr/cassette/serializers/psych.rb +24 -0
  41. data/lib/vcr/cassette/serializers/syck.rb +35 -0
  42. data/lib/vcr/cassette/serializers/yaml.rb +24 -0
  43. data/lib/vcr/configuration.rb +6 -1
  44. data/lib/vcr/errors.rb +1 -1
  45. data/lib/vcr/library_hooks/excon.rb +1 -7
  46. data/lib/vcr/library_hooks/typhoeus.rb +6 -22
  47. data/lib/vcr/library_hooks/webmock.rb +1 -1
  48. data/lib/vcr/middleware/faraday.rb +1 -1
  49. data/lib/vcr/request_matcher_registry.rb +43 -30
  50. data/lib/vcr/structs.rb +209 -0
  51. data/lib/vcr/tasks/vcr.rake +9 -0
  52. data/lib/vcr/version.rb +1 -1
  53. data/spec/fixtures/cassette_spec/1_x_cassette.yml +110 -0
  54. data/spec/fixtures/cassette_spec/example.yml +79 -78
  55. data/spec/fixtures/cassette_spec/with_localhost_requests.yml +79 -77
  56. data/spec/fixtures/fake_example.com_responses.yml +78 -76
  57. data/spec/fixtures/match_requests_on.yml +147 -145
  58. data/spec/monkey_patches.rb +5 -5
  59. data/spec/support/http_library_adapters.rb +48 -0
  60. data/spec/support/shared_example_groups/hook_into_http_library.rb +53 -20
  61. data/spec/support/sinatra_app.rb +12 -0
  62. data/spec/vcr/cassette/http_interaction_list_spec.rb +1 -1
  63. data/spec/vcr/cassette/migrator_spec.rb +183 -0
  64. data/spec/vcr/cassette/serializers_spec.rb +122 -0
  65. data/spec/vcr/cassette_spec.rb +147 -83
  66. data/spec/vcr/configuration_spec.rb +11 -1
  67. data/spec/vcr/library_hooks/typhoeus_spec.rb +3 -3
  68. data/spec/vcr/library_hooks/webmock_spec.rb +7 -1
  69. data/spec/vcr/request_ignorer_spec.rb +1 -1
  70. data/spec/vcr/request_matcher_registry_spec.rb +46 -4
  71. data/spec/vcr/structs_spec.rb +309 -0
  72. data/spec/vcr_spec.rb +7 -0
  73. data/vcr.gemspec +9 -12
  74. metadata +75 -61
  75. data/lib/vcr/structs/http_interaction.rb +0 -58
  76. data/lib/vcr/structs/normalizers/body.rb +0 -24
  77. data/lib/vcr/structs/normalizers/header.rb +0 -64
  78. data/lib/vcr/structs/normalizers/status_message.rb +0 -17
  79. data/lib/vcr/structs/normalizers/uri.rb +0 -34
  80. data/lib/vcr/structs/request.rb +0 -13
  81. data/lib/vcr/structs/response.rb +0 -13
  82. data/lib/vcr/structs/response_status.rb +0 -5
  83. data/lib/vcr/util/yaml.rb +0 -11
  84. data/spec/support/shared_example_groups/normalizers.rb +0 -94
  85. data/spec/vcr/structs/http_interaction_spec.rb +0 -89
  86. data/spec/vcr/structs/request_spec.rb +0 -39
  87. data/spec/vcr/structs/response_spec.rb +0 -44
  88. data/spec/vcr/structs/response_status_spec.rb +0 -9
data/spec/vcr_spec.rb CHANGED
@@ -157,6 +157,13 @@ describe VCR do
157
157
  end
158
158
  end
159
159
 
160
+ describe '.serializers' do
161
+ it 'always returns the same memoized cassette serializers instance' do
162
+ VCR.cassette_serializers.should be_a(VCR::Cassette::Serializers)
163
+ VCR.cassette_serializers.should be(VCR.cassette_serializers)
164
+ end
165
+ end
166
+
160
167
  describe '.configuration' do
161
168
  it 'returns the configuration object' do
162
169
  VCR.configuration.should be_a(VCR::Configuration)
data/vcr.gemspec CHANGED
@@ -21,7 +21,10 @@ Gem::Specification.new do |s|
21
21
  'bundler' => '~> 1.0.7',
22
22
  'rake' => '~> 0.9.2',
23
23
 
24
- 'rspec' => '~> 2.6',
24
+ 'cucumber' => '~> 1.0.3',
25
+ 'aruba' => '~> 0.4.6',
26
+
27
+ 'rspec' => '~> 2.7',
25
28
  'shoulda' => '~> 2.9.2',
26
29
 
27
30
  'fakeweb' => '~> 1.3.0',
@@ -34,24 +37,18 @@ Gem::Specification.new do |s|
34
37
 
35
38
  'timecop' => '~> 0.3.5',
36
39
  'rack' => '1.1.0',
37
- 'sinatra' => '~> 1.1.0'
38
- }.each do |lib, version|
39
- s.add_development_dependency lib, version
40
- end
40
+ 'sinatra' => '~> 1.1.0',
41
41
 
42
- # Cucumber 1.0.2 seems to have issues installing on 1.8.6 :(.
43
- {
44
- 'cucumber' => '~> 1.0.3',
45
- 'aruba' => '~> 0.4.6',
42
+ 'multi_json' => '~> 1.0.3'
46
43
  }.each do |lib, version|
47
44
  s.add_development_dependency lib, version
48
- end unless RUBY_VERSION == '1.8.6'
45
+ end
49
46
 
50
47
  {
51
48
  'patron' => '~> 0.4.15',
52
49
  'em-http-request' => '~> 0.3.0',
53
- 'curb' => '~> 0.7.15',
54
- 'typhoeus' => '~> 0.2.1'
50
+ 'curb' => '0.7.15',
51
+ 'typhoeus' => '~> 0.3.2'
55
52
  }.each do |lib, version|
56
53
  s.add_development_dependency lib, version
57
54
  end unless RUBY_PLATFORM == 'java'
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196449
4
+ hash: 62196455
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 1
12
- version: 2.0.0.beta1
11
+ - 2
12
+ version: 2.0.0.beta2
13
13
  platform: ruby
14
14
  authors:
15
15
  - Myron Marston
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-10-09 00:00:00 Z
20
+ date: 2011-11-07 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -138,11 +138,11 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- hash: 15
141
+ hash: 13
142
142
  segments:
143
143
  - 2
144
- - 6
145
- version: "2.6"
144
+ - 7
145
+ version: "2.7"
146
146
  name: rspec
147
147
  type: :development
148
148
  prerelease: false
@@ -151,15 +151,15 @@ dependencies:
151
151
  version_requirements: &id009 !ruby/object:Gem::Requirement
152
152
  none: false
153
153
  requirements:
154
- - - "="
154
+ - - ~>
155
155
  - !ruby/object:Gem::Version
156
- hash: 19
156
+ hash: 17
157
157
  segments:
158
158
  - 1
159
- - 1
160
159
  - 0
161
- version: 1.1.0
162
- name: rack
160
+ - 3
161
+ version: 1.0.3
162
+ name: multi_json
163
163
  type: :development
164
164
  prerelease: false
165
165
  requirement: *id009
@@ -167,7 +167,7 @@ dependencies:
167
167
  version_requirements: &id010 !ruby/object:Gem::Requirement
168
168
  none: false
169
169
  requirements:
170
- - - ~>
170
+ - - "="
171
171
  - !ruby/object:Gem::Version
172
172
  hash: 19
173
173
  segments:
@@ -175,7 +175,7 @@ dependencies:
175
175
  - 1
176
176
  - 0
177
177
  version: 1.1.0
178
- name: sinatra
178
+ name: rack
179
179
  type: :development
180
180
  prerelease: false
181
181
  requirement: *id010
@@ -185,13 +185,13 @@ dependencies:
185
185
  requirements:
186
186
  - - ~>
187
187
  - !ruby/object:Gem::Version
188
- hash: 25
188
+ hash: 3
189
189
  segments:
190
- - 1
191
190
  - 0
192
- - 7
193
- version: 1.0.7
194
- name: bundler
191
+ - 4
192
+ - 6
193
+ version: 0.4.6
194
+ name: aruba
195
195
  type: :development
196
196
  prerelease: false
197
197
  requirement: *id011
@@ -201,13 +201,13 @@ dependencies:
201
201
  requirements:
202
202
  - - ~>
203
203
  - !ruby/object:Gem::Version
204
- hash: 13
204
+ hash: 19
205
205
  segments:
206
+ - 1
207
+ - 1
206
208
  - 0
207
- - 6
208
- - 5
209
- version: 0.6.5
210
- name: excon
209
+ version: 1.1.0
210
+ name: sinatra
211
211
  type: :development
212
212
  prerelease: false
213
213
  requirement: *id012
@@ -217,13 +217,13 @@ dependencies:
217
217
  requirements:
218
218
  - - ~>
219
219
  - !ruby/object:Gem::Version
220
- hash: 3
220
+ hash: 25
221
221
  segments:
222
222
  - 1
223
+ - 0
223
224
  - 7
224
- - 4
225
- version: 1.7.4
226
- name: webmock
225
+ version: 1.0.7
226
+ name: bundler
227
227
  type: :development
228
228
  prerelease: false
229
229
  requirement: *id013
@@ -233,13 +233,13 @@ dependencies:
233
233
  requirements:
234
234
  - - ~>
235
235
  - !ruby/object:Gem::Version
236
- hash: 3
236
+ hash: 13
237
237
  segments:
238
238
  - 0
239
- - 4
240
239
  - 6
241
- version: 0.4.6
242
- name: aruba
240
+ - 5
241
+ version: 0.6.5
242
+ name: excon
243
243
  type: :development
244
244
  prerelease: false
245
245
  requirement: *id014
@@ -264,6 +264,22 @@ dependencies:
264
264
  none: false
265
265
  requirements:
266
266
  - - ~>
267
+ - !ruby/object:Gem::Version
268
+ hash: 3
269
+ segments:
270
+ - 1
271
+ - 7
272
+ - 4
273
+ version: 1.7.4
274
+ name: webmock
275
+ type: :development
276
+ prerelease: false
277
+ requirement: *id016
278
+ - !ruby/object:Gem::Dependency
279
+ version_requirements: &id017 !ruby/object:Gem::Requirement
280
+ none: false
281
+ requirements:
282
+ - - "="
267
283
  - !ruby/object:Gem::Version
268
284
  hash: 29
269
285
  segments:
@@ -274,9 +290,9 @@ dependencies:
274
290
  name: curb
275
291
  type: :development
276
292
  prerelease: false
277
- requirement: *id016
293
+ requirement: *id017
278
294
  - !ruby/object:Gem::Dependency
279
- version_requirements: &id017 !ruby/object:Gem::Requirement
295
+ version_requirements: &id018 !ruby/object:Gem::Requirement
280
296
  none: false
281
297
  requirements:
282
298
  - - ~>
@@ -290,9 +306,9 @@ dependencies:
290
306
  name: patron
291
307
  type: :development
292
308
  prerelease: false
293
- requirement: *id017
309
+ requirement: *id018
294
310
  - !ruby/object:Gem::Dependency
295
- version_requirements: &id018 !ruby/object:Gem::Requirement
311
+ version_requirements: &id019 !ruby/object:Gem::Requirement
296
312
  none: false
297
313
  requirements:
298
314
  - - ~>
@@ -306,23 +322,23 @@ dependencies:
306
322
  name: em-http-request
307
323
  type: :development
308
324
  prerelease: false
309
- requirement: *id018
325
+ requirement: *id019
310
326
  - !ruby/object:Gem::Dependency
311
- version_requirements: &id019 !ruby/object:Gem::Requirement
327
+ version_requirements: &id020 !ruby/object:Gem::Requirement
312
328
  none: false
313
329
  requirements:
314
330
  - - ~>
315
331
  - !ruby/object:Gem::Version
316
- hash: 21
332
+ hash: 23
317
333
  segments:
318
334
  - 0
335
+ - 3
319
336
  - 2
320
- - 1
321
- version: 0.2.1
337
+ version: 0.3.2
322
338
  name: typhoeus
323
339
  type: :development
324
340
  prerelease: false
325
- requirement: *id019
341
+ requirement: *id020
326
342
  description: VCR provides a simple API to record and replay your test suite's HTTP interactions. It works with a variety of HTTP client libraries, HTTP stubbing libraries and testing frameworks.
327
343
  email: myron.marston@gmail.com
328
344
  executables: []
@@ -344,6 +360,7 @@ files:
344
360
  - LICENSE
345
361
  - README.md
346
362
  - Rakefile
363
+ - Upgrade.md
347
364
  - benchmarks/http_stubbing_libraries.rb
348
365
  - cucumber.yml
349
366
  - features/.nav
@@ -394,7 +411,13 @@ files:
394
411
  - lib/vcr.rb
395
412
  - lib/vcr/cassette.rb
396
413
  - lib/vcr/cassette/http_interaction_list.rb
414
+ - lib/vcr/cassette/migrator.rb
397
415
  - lib/vcr/cassette/reader.rb
416
+ - lib/vcr/cassette/serializers.rb
417
+ - lib/vcr/cassette/serializers/json.rb
418
+ - lib/vcr/cassette/serializers/psych.rb
419
+ - lib/vcr/cassette/serializers/syck.rb
420
+ - lib/vcr/cassette/serializers/yaml.rb
398
421
  - lib/vcr/configuration.rb
399
422
  - lib/vcr/deprecations.rb
400
423
  - lib/vcr/errors.rb
@@ -410,26 +433,20 @@ files:
410
433
  - lib/vcr/request_handler.rb
411
434
  - lib/vcr/request_ignorer.rb
412
435
  - lib/vcr/request_matcher_registry.rb
413
- - lib/vcr/structs/http_interaction.rb
414
- - lib/vcr/structs/normalizers/body.rb
415
- - lib/vcr/structs/normalizers/header.rb
416
- - lib/vcr/structs/normalizers/status_message.rb
417
- - lib/vcr/structs/normalizers/uri.rb
418
- - lib/vcr/structs/request.rb
419
- - lib/vcr/structs/response.rb
420
- - lib/vcr/structs/response_status.rb
436
+ - lib/vcr/structs.rb
437
+ - lib/vcr/tasks/vcr.rake
421
438
  - lib/vcr/test_frameworks/cucumber.rb
422
439
  - lib/vcr/test_frameworks/rspec.rb
423
440
  - lib/vcr/util/hooks.rb
424
441
  - lib/vcr/util/internet_connection.rb
425
442
  - lib/vcr/util/variable_args_block_caller.rb
426
443
  - lib/vcr/util/version_checker.rb
427
- - lib/vcr/util/yaml.rb
428
444
  - lib/vcr/version.rb
429
445
  - script/FullBuildRakeFile
430
446
  - script/full_build
431
447
  - script/spec
432
448
  - spec/capture_warnings.rb
449
+ - spec/fixtures/cassette_spec/1_x_cassette.yml
433
450
  - spec/fixtures/cassette_spec/empty.yml
434
451
  - spec/fixtures/cassette_spec/example.yml
435
452
  - spec/fixtures/cassette_spec/with_localhost_requests.yml
@@ -441,12 +458,13 @@ files:
441
458
  - spec/support/http_library_adapters.rb
442
459
  - spec/support/ruby_interpreter.rb
443
460
  - spec/support/shared_example_groups/hook_into_http_library.rb
444
- - spec/support/shared_example_groups/normalizers.rb
445
461
  - spec/support/shared_example_groups/version_checking.rb
446
462
  - spec/support/sinatra_app.rb
447
463
  - spec/support/vcr_localhost_server.rb
448
464
  - spec/vcr/cassette/http_interaction_list_spec.rb
465
+ - spec/vcr/cassette/migrator_spec.rb
449
466
  - spec/vcr/cassette/reader_spec.rb
467
+ - spec/vcr/cassette/serializers_spec.rb
450
468
  - spec/vcr/cassette_spec.rb
451
469
  - spec/vcr/configuration_spec.rb
452
470
  - spec/vcr/deprecations_spec.rb
@@ -460,10 +478,7 @@ files:
460
478
  - spec/vcr/middleware/rack_spec.rb
461
479
  - spec/vcr/request_ignorer_spec.rb
462
480
  - spec/vcr/request_matcher_registry_spec.rb
463
- - spec/vcr/structs/http_interaction_spec.rb
464
- - spec/vcr/structs/request_spec.rb
465
- - spec/vcr/structs/response_spec.rb
466
- - spec/vcr/structs/response_status_spec.rb
481
+ - spec/vcr/structs_spec.rb
467
482
  - spec/vcr/test_frameworks/cucumber_spec.rb
468
483
  - spec/vcr/test_frameworks/rspec_spec.rb
469
484
  - spec/vcr/util/hooks_spec.rb
@@ -554,6 +569,7 @@ test_files:
554
569
  - features/test_frameworks/shoulda.feature
555
570
  - features/test_frameworks/test_unit.feature
556
571
  - spec/capture_warnings.rb
572
+ - spec/fixtures/cassette_spec/1_x_cassette.yml
557
573
  - spec/fixtures/cassette_spec/empty.yml
558
574
  - spec/fixtures/cassette_spec/example.yml
559
575
  - spec/fixtures/cassette_spec/with_localhost_requests.yml
@@ -565,12 +581,13 @@ test_files:
565
581
  - spec/support/http_library_adapters.rb
566
582
  - spec/support/ruby_interpreter.rb
567
583
  - spec/support/shared_example_groups/hook_into_http_library.rb
568
- - spec/support/shared_example_groups/normalizers.rb
569
584
  - spec/support/shared_example_groups/version_checking.rb
570
585
  - spec/support/sinatra_app.rb
571
586
  - spec/support/vcr_localhost_server.rb
572
587
  - spec/vcr/cassette/http_interaction_list_spec.rb
588
+ - spec/vcr/cassette/migrator_spec.rb
573
589
  - spec/vcr/cassette/reader_spec.rb
590
+ - spec/vcr/cassette/serializers_spec.rb
574
591
  - spec/vcr/cassette_spec.rb
575
592
  - spec/vcr/configuration_spec.rb
576
593
  - spec/vcr/deprecations_spec.rb
@@ -584,10 +601,7 @@ test_files:
584
601
  - spec/vcr/middleware/rack_spec.rb
585
602
  - spec/vcr/request_ignorer_spec.rb
586
603
  - spec/vcr/request_matcher_registry_spec.rb
587
- - spec/vcr/structs/http_interaction_spec.rb
588
- - spec/vcr/structs/request_spec.rb
589
- - spec/vcr/structs/response_spec.rb
590
- - spec/vcr/structs/response_status_spec.rb
604
+ - spec/vcr/structs_spec.rb
591
605
  - spec/vcr/test_frameworks/cucumber_spec.rb
592
606
  - spec/vcr/test_frameworks/rspec_spec.rb
593
607
  - spec/vcr/util/hooks_spec.rb
@@ -1,58 +0,0 @@
1
- require 'forwardable'
2
- require 'vcr/structs/normalizers/body'
3
- require 'vcr/structs/normalizers/header'
4
- require 'vcr/structs/normalizers/status_message'
5
- require 'vcr/structs/normalizers/uri'
6
- require 'vcr/structs/request'
7
- require 'vcr/structs/response'
8
-
9
- module VCR
10
- class HTTPInteraction < Struct.new(:request, :response)
11
- extend ::Forwardable
12
- def_delegators :request, :uri, :method
13
-
14
- def ignore!
15
- # we don't want to store any additional
16
- # ivars on this object because that would get
17
- # serialized with the object...so we redefine
18
- # `ignored?` instead.
19
- (class << self; self; end).class_eval do
20
- undef ignored?
21
- def ignored?; true; end
22
- end
23
- end
24
-
25
- def ignored?
26
- false
27
- end
28
-
29
- def filter!(text, replacement_text)
30
- return self if [text, replacement_text].any? { |t| t.to_s.empty? }
31
- filter_object!(self, text, replacement_text)
32
- end
33
-
34
- private
35
-
36
- def filter_object!(object, text, replacement_text)
37
- if object.respond_to?(:gsub)
38
- object.gsub!(text, replacement_text) if object.include?(text)
39
- elsif Hash === object
40
- filter_hash!(object, text, replacement_text)
41
- elsif object.respond_to?(:each)
42
- # This handles nested arrays and structs
43
- object.each { |o| filter_object!(o, text, replacement_text) }
44
- end
45
-
46
- object
47
- end
48
-
49
- def filter_hash!(hash, text, replacement_text)
50
- filter_object!(hash.values, text, replacement_text)
51
-
52
- hash.keys.each do |k|
53
- new_key = filter_object!(k.dup, text, replacement_text)
54
- hash[new_key] = hash.delete(k) unless k == new_key
55
- end
56
- end
57
- end
58
- end