vcr 2.0.0.rc1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/.gitignore +2 -0
  2. data/.limited_red +1 -0
  3. data/.travis.yml +10 -1
  4. data/.yardopts +9 -0
  5. data/CHANGELOG.md +51 -1
  6. data/Gemfile +5 -1
  7. data/LICENSE +1 -1
  8. data/README.md +23 -28
  9. data/Rakefile +63 -18
  10. data/Upgrade.md +200 -0
  11. data/features/.nav +2 -0
  12. data/features/cassettes/automatic_re_recording.feature +19 -15
  13. data/features/cassettes/dynamic_erb.feature +12 -4
  14. data/features/cassettes/exclusive.feature +31 -23
  15. data/features/cassettes/format.feature +54 -30
  16. data/features/cassettes/naming.feature +1 -1
  17. data/features/cassettes/update_content_length_header.feature +16 -12
  18. data/features/configuration/allow_http_connections_when_no_cassette.feature +1 -1
  19. data/features/configuration/debug_logging.feature +52 -0
  20. data/features/configuration/filter_sensitive_data.feature +4 -4
  21. data/features/configuration/hook_into.feature +5 -2
  22. data/features/configuration/ignore_request.feature +5 -3
  23. data/features/configuration/preserve_exact_body_bytes.feature +103 -0
  24. data/features/hooks/after_http_request.feature +17 -4
  25. data/features/hooks/around_http_request.feature +2 -1
  26. data/features/hooks/before_http_request.feature +25 -8
  27. data/features/hooks/before_playback.feature +16 -12
  28. data/features/hooks/before_record.feature +2 -2
  29. data/features/http_libraries/em_http_request.feature +82 -58
  30. data/features/http_libraries/net_http.feature +6 -6
  31. data/features/middleware/faraday.feature +2 -1
  32. data/features/middleware/rack.feature +2 -2
  33. data/features/record_modes/all.feature +19 -15
  34. data/features/record_modes/new_episodes.feature +17 -13
  35. data/features/record_modes/none.feature +15 -11
  36. data/features/record_modes/once.feature +16 -12
  37. data/features/request_matching/body.feature +28 -20
  38. data/features/request_matching/custom_matcher.feature +28 -20
  39. data/features/request_matching/headers.feature +34 -26
  40. data/features/request_matching/host.feature +28 -20
  41. data/features/request_matching/identical_request_sequence.feature +28 -20
  42. data/features/request_matching/method.feature +28 -20
  43. data/features/request_matching/path.feature +28 -20
  44. data/features/request_matching/playback_repeats.feature +28 -20
  45. data/features/request_matching/uri.feature +28 -20
  46. data/features/request_matching/uri_without_param.feature +28 -20
  47. data/features/support/env.rb +7 -6
  48. data/features/support/vcr_cucumber_helpers.rb +1 -0
  49. data/features/test_frameworks/cucumber.feature +8 -8
  50. data/features/test_frameworks/rspec_macro.feature +4 -4
  51. data/features/test_frameworks/rspec_metadata.feature +6 -6
  52. data/features/test_frameworks/shoulda.feature +1 -1
  53. data/features/test_frameworks/test_unit.feature +1 -1
  54. data/lib/vcr.rb +156 -5
  55. data/lib/vcr/cassette.rb +80 -30
  56. data/lib/vcr/cassette/http_interaction_list.rb +33 -4
  57. data/lib/vcr/cassette/migrator.rb +2 -3
  58. data/lib/vcr/cassette/reader.rb +1 -0
  59. data/lib/vcr/cassette/serializers.rb +22 -0
  60. data/lib/vcr/cassette/serializers/json.rb +27 -2
  61. data/lib/vcr/cassette/serializers/psych.rb +26 -2
  62. data/lib/vcr/cassette/serializers/syck.rb +28 -2
  63. data/lib/vcr/cassette/serializers/yaml.rb +28 -2
  64. data/lib/vcr/configuration.rb +348 -10
  65. data/lib/vcr/deprecations.rb +8 -0
  66. data/lib/vcr/errors.rb +40 -0
  67. data/lib/vcr/extensions/net_http_response.rb +12 -11
  68. data/lib/vcr/library_hooks.rb +1 -0
  69. data/lib/vcr/library_hooks/excon.rb +24 -3
  70. data/lib/vcr/library_hooks/fakeweb.rb +32 -16
  71. data/lib/vcr/library_hooks/faraday.rb +3 -0
  72. data/lib/vcr/library_hooks/typhoeus.rb +40 -37
  73. data/lib/vcr/library_hooks/webmock.rb +54 -34
  74. data/lib/vcr/middleware/faraday.rb +13 -0
  75. data/lib/vcr/middleware/rack.rb +35 -0
  76. data/lib/vcr/request_handler.rb +60 -8
  77. data/lib/vcr/request_ignorer.rb +1 -0
  78. data/lib/vcr/request_matcher_registry.rb +28 -0
  79. data/lib/vcr/structs.rb +245 -38
  80. data/lib/vcr/test_frameworks/cucumber.rb +10 -0
  81. data/lib/vcr/test_frameworks/rspec.rb +26 -1
  82. data/lib/vcr/util/hooks.rb +29 -27
  83. data/lib/vcr/util/internet_connection.rb +2 -0
  84. data/lib/vcr/util/logger.rb +25 -0
  85. data/lib/vcr/util/variable_args_block_caller.rb +1 -0
  86. data/lib/vcr/util/version_checker.rb +1 -0
  87. data/lib/vcr/version.rb +8 -1
  88. data/spec/capture_warnings.rb +3 -3
  89. data/spec/monkey_patches.rb +28 -13
  90. data/spec/spec_helper.rb +17 -0
  91. data/spec/support/http_library_adapters.rb +7 -4
  92. data/spec/support/shared_example_groups/hook_into_http_library.rb +96 -32
  93. data/spec/support/shared_example_groups/request_hooks.rb +9 -8
  94. data/spec/support/sinatra_app.rb +3 -1
  95. data/spec/support/vcr_localhost_server.rb +1 -0
  96. data/spec/vcr/cassette/http_interaction_list_spec.rb +119 -54
  97. data/spec/vcr/cassette/migrator_spec.rb +19 -6
  98. data/spec/vcr/cassette/serializers_spec.rb +51 -6
  99. data/spec/vcr/cassette_spec.rb +44 -19
  100. data/spec/vcr/configuration_spec.rb +91 -6
  101. data/spec/vcr/library_hooks/excon_spec.rb +54 -16
  102. data/spec/vcr/library_hooks/fakeweb_spec.rb +12 -21
  103. data/spec/vcr/library_hooks/typhoeus_spec.rb +2 -29
  104. data/spec/vcr/library_hooks/webmock_spec.rb +4 -18
  105. data/spec/vcr/middleware/faraday_spec.rb +1 -16
  106. data/spec/vcr/structs_spec.rb +194 -61
  107. data/spec/vcr/test_frameworks/rspec_spec.rb +10 -0
  108. data/spec/vcr/util/hooks_spec.rb +104 -56
  109. data/spec/vcr/util/version_checker_spec.rb +45 -0
  110. data/spec/vcr_spec.rb +11 -0
  111. data/vcr.gemspec +30 -34
  112. metadata +149 -95
  113. data/spec/support/shared_example_groups/version_checking.rb +0 -34
@@ -9,37 +9,45 @@ Feature: Matching on Host
9
9
  Background:
10
10
  Given a previously recorded cassette file "cassettes/example.yml" with:
11
11
  """
12
- ---
13
- http_interactions:
14
- - request:
12
+ ---
13
+ http_interactions:
14
+ - request:
15
15
  method: post
16
16
  uri: http://host1.com/some/long/path
17
- body: ''
17
+ body:
18
+ encoding: UTF-8
19
+ string: ""
18
20
  headers: {}
19
- response:
20
- status:
21
+ response:
22
+ status:
21
23
  code: 200
22
24
  message: OK
23
- headers:
24
- Content-Length:
25
- - '14'
26
- body: host1 response
27
- http_version: '1.1'
25
+ headers:
26
+ Content-Length:
27
+ - "14"
28
+ body:
29
+ encoding: UTF-8
30
+ string: host1 response
31
+ http_version: "1.1"
28
32
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
29
- - request:
33
+ - request:
30
34
  method: post
31
35
  uri: http://host2.com/some/other/long/path
32
- body: ''
36
+ body:
37
+ encoding: UTF-8
38
+ string: ""
33
39
  headers: {}
34
- response:
35
- status:
40
+ response:
41
+ status:
36
42
  code: 200
37
43
  message: OK
38
- headers:
39
- Content-Length:
40
- - '16'
41
- body: host2 response
42
- http_version: '1.1'
44
+ headers:
45
+ Content-Length:
46
+ - "16"
47
+ body:
48
+ encoding: UTF-8
49
+ string: host2 response
50
+ http_version: "1.1"
43
51
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
44
52
  recorded_with: VCR 2.0.0
45
53
  """
@@ -8,37 +8,45 @@ Feature: Identical requests are replayed in sequence
8
8
  Scenario Outline: identical requests are replayed in sequence
9
9
  Given a previously recorded cassette file "cassettes/example.yml" with:
10
10
  """
11
- ---
12
- http_interactions:
13
- - request:
11
+ ---
12
+ http_interactions:
13
+ - request:
14
14
  method: get
15
15
  uri: http://example.com/foo
16
- body: ''
16
+ body:
17
+ encoding: UTF-8
18
+ string: ""
17
19
  headers: {}
18
- response:
19
- status:
20
+ response:
21
+ status:
20
22
  code: 200
21
23
  message: OK
22
- headers:
23
- Content-Length:
24
- - '10'
25
- body: Response 1
26
- http_version: '1.1'
24
+ headers:
25
+ Content-Length:
26
+ - "10"
27
+ body:
28
+ encoding: UTF-8
29
+ string: Response 1
30
+ http_version: "1.1"
27
31
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
28
- - request:
32
+ - request:
29
33
  method: get
30
34
  uri: http://example.com/foo
31
- body: ''
35
+ body:
36
+ encoding: UTF-8
37
+ string: ""
32
38
  headers: {}
33
- response:
34
- status:
39
+ response:
40
+ status:
35
41
  code: 200
36
42
  message: OK
37
- headers:
38
- Content-Length:
39
- - '10'
40
- body: Response 2
41
- http_version: '1.1'
43
+ headers:
44
+ Content-Length:
45
+ - "10"
46
+ body:
47
+ encoding: UTF-8
48
+ string: Response 2
49
+ http_version: "1.1"
42
50
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
43
51
  recorded_with: VCR 2.0.0
44
52
  """
@@ -10,37 +10,45 @@ Feature: Matching on Method
10
10
  Background:
11
11
  Given a previously recorded cassette file "cassettes/example.yml" with:
12
12
  """
13
- ---
14
- http_interactions:
15
- - request:
13
+ ---
14
+ http_interactions:
15
+ - request:
16
16
  method: post
17
17
  uri: http://post-request.com/
18
- body: ''
18
+ body:
19
+ encoding: UTF-8
20
+ string: ""
19
21
  headers: {}
20
- response:
21
- status:
22
+ response:
23
+ status:
22
24
  code: 200
23
25
  message: OK
24
- headers:
25
- Content-Length:
26
- - '13'
27
- body: post response
28
- http_version: '1.1'
26
+ headers:
27
+ Content-Length:
28
+ - "13"
29
+ body:
30
+ encoding: UTF-8
31
+ string: post response
32
+ http_version: "1.1"
29
33
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
30
- - request:
34
+ - request:
31
35
  method: get
32
36
  uri: http://get-request.com/
33
- body: ''
37
+ body:
38
+ encoding: UTF-8
39
+ string: ""
34
40
  headers: {}
35
- response:
36
- status:
41
+ response:
42
+ status:
37
43
  code: 200
38
44
  message: OK
39
- headers:
40
- Content-Length:
41
- - '12'
42
- body: get response
43
- http_version: '1.1'
45
+ headers:
46
+ Content-Length:
47
+ - "12"
48
+ body:
49
+ encoding: UTF-8
50
+ string: get response
51
+ http_version: "1.1"
44
52
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
45
53
  recorded_with: VCR 2.0.0
46
54
  """
@@ -10,37 +10,45 @@ Feature: Matching on Path
10
10
  Background:
11
11
  Given a previously recorded cassette file "cassettes/example.yml" with:
12
12
  """
13
- ---
14
- http_interactions:
15
- - request:
13
+ ---
14
+ http_interactions:
15
+ - request:
16
16
  method: post
17
17
  uri: http://host1.com/about?date=2011-09-01
18
- body: ''
18
+ body:
19
+ encoding: UTF-8
20
+ string: ""
19
21
  headers: {}
20
- response:
21
- status:
22
+ response:
23
+ status:
22
24
  code: 200
23
25
  message: OK
24
- headers:
25
- Content-Length:
26
- - '14'
27
- body: about response
28
- http_version: '1.1'
26
+ headers:
27
+ Content-Length:
28
+ - "14"
29
+ body:
30
+ encoding: UTF-8
31
+ string: about response
32
+ http_version: "1.1"
29
33
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
30
- - request:
34
+ - request:
31
35
  method: post
32
36
  uri: http://host2.com/home?date=2011-09-01
33
- body: ''
37
+ body:
38
+ encoding: UTF-8
39
+ string: ""
34
40
  headers: {}
35
- response:
36
- status:
41
+ response:
42
+ status:
37
43
  code: 200
38
44
  message: OK
39
- headers:
40
- Content-Length:
41
- - '15'
42
- body: home response
43
- http_version: '1.1'
45
+ headers:
46
+ Content-Length:
47
+ - "15"
48
+ body:
49
+ encoding: UTF-8
50
+ string: home response
51
+ http_version: "1.1"
44
52
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
45
53
  recorded_with: VCR 2.0.0
46
54
  """
@@ -16,37 +16,45 @@ Feature: Playback repeats
16
16
  Scenario: Responses do not repeat by default
17
17
  Given a previously recorded cassette file "cassettes/example.yml" with:
18
18
  """
19
- ---
20
- http_interactions:
21
- - request:
19
+ ---
20
+ http_interactions:
21
+ - request:
22
22
  method: get
23
23
  uri: http://example.com/foo
24
- body: ''
24
+ body:
25
+ encoding: UTF-8
26
+ string: ""
25
27
  headers: {}
26
- response:
27
- status:
28
+ response:
29
+ status:
28
30
  code: 200
29
31
  message: OK
30
- headers:
31
- Content-Length:
32
- - '10'
33
- body: Response 1
34
- http_version: '1.1'
32
+ headers:
33
+ Content-Length:
34
+ - "10"
35
+ body:
36
+ encoding: UTF-8
37
+ string: Response 1
38
+ http_version: "1.1"
35
39
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
36
- - request:
40
+ - request:
37
41
  method: get
38
42
  uri: http://example.com/foo
39
- body: ''
43
+ body:
44
+ encoding: UTF-8
45
+ string: ""
40
46
  headers: {}
41
- response:
42
- status:
47
+ response:
48
+ status:
43
49
  code: 200
44
50
  message: OK
45
- headers:
46
- Content-Length:
47
- - '10'
48
- body: Response 2
49
- http_version: '1.1'
51
+ headers:
52
+ Content-Length:
53
+ - "10"
54
+ body:
55
+ encoding: UTF-8
56
+ string: Response 2
57
+ http_version: "1.1"
50
58
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
51
59
  recorded_with: VCR 2.0.0
52
60
  """
@@ -8,37 +8,45 @@ Feature: Matching on URI
8
8
  Background:
9
9
  Given a previously recorded cassette file "cassettes/example.yml" with:
10
10
  """
11
- ---
12
- http_interactions:
13
- - request:
11
+ ---
12
+ http_interactions:
13
+ - request:
14
14
  method: post
15
15
  uri: http://example.com/foo
16
- body: ''
16
+ body:
17
+ encoding: UTF-8
18
+ string: ""
17
19
  headers: {}
18
- response:
19
- status:
20
+ response:
21
+ status:
20
22
  code: 200
21
23
  message: OK
22
- headers:
23
- Content-Length:
24
- - '12'
25
- body: foo response
26
- http_version: '1.1'
24
+ headers:
25
+ Content-Length:
26
+ - "12"
27
+ body:
28
+ encoding: UTF-8
29
+ string: foo response
30
+ http_version: "1.1"
27
31
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
28
- - request:
32
+ - request:
29
33
  method: post
30
34
  uri: http://example.com/bar
31
- body: ''
35
+ body:
36
+ encoding: UTF-8
37
+ string: ""
32
38
  headers: {}
33
- response:
34
- status:
39
+ response:
40
+ status:
35
41
  code: 200
36
42
  message: OK
37
- headers:
38
- Content-Length:
39
- - '12'
40
- body: bar response
41
- http_version: '1.1'
43
+ headers:
44
+ Content-Length:
45
+ - "12"
46
+ body:
47
+ encoding: UTF-8
48
+ string: bar response
49
+ http_version: "1.1"
42
50
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
43
51
  recorded_with: VCR 2.0.0
44
52
  """
@@ -16,37 +16,45 @@ Feature: URI without param(s)
16
16
  Background:
17
17
  Given a previously recorded cassette file "cassettes/example.yml" with:
18
18
  """
19
- ---
20
- http_interactions:
21
- - request:
19
+ ---
20
+ http_interactions:
21
+ - request:
22
22
  method: get
23
23
  uri: http://example.com/search?q=foo&timestamp=1316920490
24
- body: ''
24
+ body:
25
+ encoding: UTF-8
26
+ string: ""
25
27
  headers: {}
26
- response:
27
- status:
28
+ response:
29
+ status:
28
30
  code: 200
29
31
  message: OK
30
- headers:
31
- Content-Length:
32
- - '12'
33
- body: foo response
34
- http_version: '1.1'
32
+ headers:
33
+ Content-Length:
34
+ - "12"
35
+ body:
36
+ encoding: UTF-8
37
+ string: foo response
38
+ http_version: "1.1"
35
39
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
36
- - request:
40
+ - request:
37
41
  method: get
38
42
  uri: http://example.com/search?q=bar&timestamp=1296723437
39
- body: ''
43
+ body:
44
+ encoding: UTF-8
45
+ string: ""
40
46
  headers: {}
41
- response:
42
- status:
47
+ response:
48
+ status:
43
49
  code: 200
44
50
  message: OK
45
- headers:
46
- Content-Length:
47
- - '12'
48
- body: bar response
49
- http_version: '1.1'
51
+ headers:
52
+ Content-Length:
53
+ - "12"
54
+ body:
55
+ encoding: UTF-8
56
+ string: bar response
57
+ http_version: "1.1"
50
58
  recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
51
59
  recorded_with: VCR 2.0.0
52
60
  """