vcr 3.0.2 → 6.0.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 (140) hide show
  1. checksums.yaml +5 -5
  2. data/lib/vcr.rb +33 -1
  3. data/lib/vcr/cassette.rb +47 -12
  4. data/lib/vcr/cassette/http_interaction_list.rb +14 -9
  5. data/lib/vcr/cassette/migrator.rb +0 -5
  6. data/lib/vcr/cassette/persisters/file_system.rb +9 -1
  7. data/lib/vcr/cassette/serializers/compressed.rb +2 -2
  8. data/lib/vcr/cassette/serializers/json.rb +7 -7
  9. data/lib/vcr/cassette/serializers/psych.rb +3 -1
  10. data/lib/vcr/cassette/serializers/yaml.rb +3 -1
  11. data/lib/vcr/configuration.rb +20 -8
  12. data/lib/vcr/deprecations.rb +0 -62
  13. data/lib/vcr/errors.rb +17 -12
  14. data/lib/vcr/library_hooks/excon.rb +8 -0
  15. data/lib/vcr/library_hooks/typhoeus.rb +37 -8
  16. data/lib/vcr/linked_cassette.rb +4 -4
  17. data/lib/vcr/middleware/faraday.rb +10 -1
  18. data/lib/vcr/request_ignorer.rb +4 -1
  19. data/lib/vcr/request_matcher_registry.rb +1 -1
  20. data/lib/vcr/structs.rb +48 -32
  21. data/lib/vcr/test_frameworks/cucumber.rb +4 -4
  22. data/lib/vcr/test_frameworks/rspec.rb +12 -3
  23. data/lib/vcr/util/hooks.rb +1 -0
  24. data/lib/vcr/util/internet_connection.rb +15 -21
  25. data/lib/vcr/version.rb +1 -1
  26. metadata +36 -263
  27. data/features/CHANGELOG.md +0 -1
  28. data/features/CONTRIBUTING.md +0 -1
  29. data/features/LICENSE.md +0 -1
  30. data/features/README.md +0 -1
  31. data/features/Upgrade.md +0 -1
  32. data/features/about_these_examples.md +0 -18
  33. data/features/cassettes/allow_unused_http_interactions.feature +0 -100
  34. data/features/cassettes/automatic_re_recording.feature +0 -72
  35. data/features/cassettes/decompress.feature +0 -74
  36. data/features/cassettes/dynamic_erb.feature +0 -100
  37. data/features/cassettes/exclusive.feature +0 -126
  38. data/features/cassettes/format.feature +0 -411
  39. data/features/cassettes/freezing_time.feature +0 -68
  40. data/features/cassettes/naming.feature +0 -28
  41. data/features/cassettes/no_cassette.feature +0 -152
  42. data/features/cassettes/update_content_length_header.feature +0 -112
  43. data/features/configuration/allow_http_connections_when_no_cassette.feature +0 -55
  44. data/features/configuration/cassette_library_dir.feature +0 -31
  45. data/features/configuration/debug_logging.feature +0 -58
  46. data/features/configuration/default_cassette_options.feature +0 -100
  47. data/features/configuration/filter_sensitive_data.feature +0 -153
  48. data/features/configuration/hook_into.feature +0 -172
  49. data/features/configuration/ignore_request.feature +0 -192
  50. data/features/configuration/preserve_exact_body_bytes.feature +0 -108
  51. data/features/configuration/query_parser.feature +0 -84
  52. data/features/configuration/uri_parser.feature +0 -93
  53. data/features/getting_started.md +0 -82
  54. data/features/hooks/after_http_request.feature +0 -58
  55. data/features/hooks/around_http_request.feature +0 -57
  56. data/features/hooks/before_http_request.feature +0 -63
  57. data/features/hooks/before_playback.feature +0 -184
  58. data/features/hooks/before_record.feature +0 -172
  59. data/features/http_libraries/em_http_request.feature +0 -250
  60. data/features/http_libraries/net_http.feature +0 -179
  61. data/features/middleware/faraday.feature +0 -56
  62. data/features/middleware/rack.feature +0 -92
  63. data/features/record_modes/all.feature +0 -82
  64. data/features/record_modes/new_episodes.feature +0 -79
  65. data/features/record_modes/none.feature +0 -72
  66. data/features/record_modes/once.feature +0 -95
  67. data/features/request_matching/README.md +0 -30
  68. data/features/request_matching/body.feature +0 -91
  69. data/features/request_matching/body_as_json.feature +0 -90
  70. data/features/request_matching/custom_matcher.feature +0 -135
  71. data/features/request_matching/headers.feature +0 -85
  72. data/features/request_matching/host.feature +0 -95
  73. data/features/request_matching/identical_request_sequence.feature +0 -89
  74. data/features/request_matching/method.feature +0 -96
  75. data/features/request_matching/path.feature +0 -96
  76. data/features/request_matching/playback_repeats.feature +0 -98
  77. data/features/request_matching/query.feature +0 -97
  78. data/features/request_matching/uri.feature +0 -94
  79. data/features/request_matching/uri_without_param.feature +0 -101
  80. data/features/step_definitions/cli_steps.rb +0 -199
  81. data/features/support/env.rb +0 -46
  82. data/features/support/http_lib_filters.rb +0 -46
  83. data/features/test_frameworks/cucumber.feature +0 -211
  84. data/features/test_frameworks/rspec_macro.feature +0 -81
  85. data/features/test_frameworks/rspec_metadata.feature +0 -150
  86. data/features/test_frameworks/test_unit.feature +0 -49
  87. data/lib/vcr/extensions/net_http_response.rb +0 -36
  88. data/lib/vcr/library_hooks/fakeweb.rb +0 -197
  89. data/spec/acceptance/concurrency_spec.rb +0 -51
  90. data/spec/acceptance/threading_spec.rb +0 -34
  91. data/spec/fixtures/cassette_spec/1_x_cassette.yml +0 -110
  92. data/spec/fixtures/cassette_spec/empty.yml +0 -0
  93. data/spec/fixtures/cassette_spec/example.yml +0 -111
  94. data/spec/fixtures/cassette_spec/with_localhost_requests.yml +0 -111
  95. data/spec/fixtures/fake_example_responses.yml +0 -110
  96. data/spec/fixtures/match_requests_on.yml +0 -187
  97. data/spec/lib/vcr/cassette/erb_renderer_spec.rb +0 -53
  98. data/spec/lib/vcr/cassette/http_interaction_list_spec.rb +0 -295
  99. data/spec/lib/vcr/cassette/migrator_spec.rb +0 -196
  100. data/spec/lib/vcr/cassette/persisters/file_system_spec.rb +0 -75
  101. data/spec/lib/vcr/cassette/persisters_spec.rb +0 -39
  102. data/spec/lib/vcr/cassette/serializers_spec.rb +0 -182
  103. data/spec/lib/vcr/cassette_spec.rb +0 -618
  104. data/spec/lib/vcr/configuration_spec.rb +0 -326
  105. data/spec/lib/vcr/deprecations_spec.rb +0 -85
  106. data/spec/lib/vcr/errors_spec.rb +0 -178
  107. data/spec/lib/vcr/extensions/net_http_response_spec.rb +0 -86
  108. data/spec/lib/vcr/library_hooks/excon_spec.rb +0 -104
  109. data/spec/lib/vcr/library_hooks/fakeweb_spec.rb +0 -169
  110. data/spec/lib/vcr/library_hooks/faraday_spec.rb +0 -68
  111. data/spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb +0 -36
  112. data/spec/lib/vcr/library_hooks/typhoeus_spec.rb +0 -162
  113. data/spec/lib/vcr/library_hooks/webmock_spec.rb +0 -117
  114. data/spec/lib/vcr/library_hooks_spec.rb +0 -51
  115. data/spec/lib/vcr/middleware/faraday_spec.rb +0 -181
  116. data/spec/lib/vcr/middleware/rack_spec.rb +0 -115
  117. data/spec/lib/vcr/request_ignorer_spec.rb +0 -70
  118. data/spec/lib/vcr/request_matcher_registry_spec.rb +0 -345
  119. data/spec/lib/vcr/structs_spec.rb +0 -732
  120. data/spec/lib/vcr/test_frameworks/cucumber_spec.rb +0 -107
  121. data/spec/lib/vcr/test_frameworks/rspec_spec.rb +0 -94
  122. data/spec/lib/vcr/util/hooks_spec.rb +0 -158
  123. data/spec/lib/vcr/util/internet_connection_spec.rb +0 -37
  124. data/spec/lib/vcr/util/version_checker_spec.rb +0 -31
  125. data/spec/lib/vcr/version_spec.rb +0 -27
  126. data/spec/lib/vcr_spec.rb +0 -354
  127. data/spec/monkey_patches.rb +0 -186
  128. data/spec/spec_helper.rb +0 -63
  129. data/spec/support/configuration_stubbing.rb +0 -8
  130. data/spec/support/cucumber_helpers.rb +0 -39
  131. data/spec/support/fixnum_extension.rb +0 -10
  132. data/spec/support/http_library_adapters.rb +0 -289
  133. data/spec/support/limited_uri.rb +0 -21
  134. data/spec/support/ruby_interpreter.rb +0 -7
  135. data/spec/support/shared_example_groups/excon.rb +0 -63
  136. data/spec/support/shared_example_groups/hook_into_http_library.rb +0 -594
  137. data/spec/support/shared_example_groups/request_hooks.rb +0 -59
  138. data/spec/support/sinatra_app.rb +0 -86
  139. data/spec/support/vcr_localhost_server.rb +0 -76
  140. data/spec/support/vcr_stub_helpers.rb +0 -17
@@ -1,85 +0,0 @@
1
- Feature: Matching on Headers
2
-
3
- Use the `:headers` request matcher to match requests on the request headers.
4
-
5
- Scenario Outline: Replay interaction that matches the headers
6
- Given a previously recorded cassette file "cassettes/example.yml" with:
7
- """
8
- ---
9
- http_interactions:
10
- - request:
11
- method: post
12
- uri: http://example.net/some/long/path
13
- body:
14
- encoding: UTF-8
15
- string: ""
16
- headers:
17
- X-User-Id:
18
- - "1"
19
- response:
20
- status:
21
- code: 200
22
- message: OK
23
- headers:
24
- Content-Length:
25
- - "15"
26
- body:
27
- encoding: UTF-8
28
- string: user 1 response
29
- http_version: "1.1"
30
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
31
- - request:
32
- method: post
33
- uri: http://example.net/some/long/path
34
- body:
35
- encoding: UTF-8
36
- string: ""
37
- headers:
38
- X-User-Id:
39
- - "2"
40
- response:
41
- status:
42
- code: 200
43
- message: OK
44
- headers:
45
- Content-Length:
46
- - "15"
47
- body:
48
- encoding: UTF-8
49
- string: user 2 response
50
- http_version: "1.1"
51
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
52
- recorded_with: VCR 2.0.0
53
- """
54
- And a file named "header_matching.rb" with:
55
- """ruby
56
- include_http_adapter_for("<http_lib>")
57
-
58
- require 'vcr'
59
-
60
- VCR.configure do |c|
61
- <configuration>
62
- c.cassette_library_dir = 'cassettes'
63
- end
64
-
65
- VCR.use_cassette('example', :match_requests_on => [:headers]) do
66
- puts "Response for user 2: " + response_body_for(:get, "http://example.com/", nil, 'X-User-Id' => '2')
67
- end
68
-
69
- VCR.use_cassette('example', :match_requests_on => [:headers]) do
70
- puts "Response for user 1: " + response_body_for(:get, "http://example.com/", nil, 'X-User-Id' => '1')
71
- end
72
- """
73
- When I run `ruby header_matching.rb`
74
- Then it should pass with:
75
- """
76
- Response for user 2: user 2 response
77
- Response for user 1: user 1 response
78
- """
79
-
80
- Examples:
81
- | configuration | http_lib |
82
- | c.hook_into :webmock | curb |
83
- | c.hook_into :webmock | patron |
84
- | c.hook_into :webmock | em-http-request |
85
-
@@ -1,95 +0,0 @@
1
- Feature: Matching on Host
2
-
3
- Use the `:host` request matcher to match requests on the request host.
4
-
5
- You can use this (alone, or in combination with `:path`) as an
6
- alternative to `:uri` so that non-deterministic portions of the URI
7
- are not considered as part of the request matching.
8
-
9
- Background:
10
- Given a previously recorded cassette file "cassettes/example.yml" with:
11
- """
12
- ---
13
- http_interactions:
14
- - request:
15
- method: post
16
- uri: http://host1.com/some/long/path
17
- body:
18
- encoding: UTF-8
19
- string: ""
20
- headers: {}
21
- response:
22
- status:
23
- code: 200
24
- message: OK
25
- headers:
26
- Content-Length:
27
- - "14"
28
- body:
29
- encoding: UTF-8
30
- string: host1 response
31
- http_version: "1.1"
32
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
33
- - request:
34
- method: post
35
- uri: http://host2.com/some/other/long/path
36
- body:
37
- encoding: UTF-8
38
- string: ""
39
- headers: {}
40
- response:
41
- status:
42
- code: 200
43
- message: OK
44
- headers:
45
- Content-Length:
46
- - "16"
47
- body:
48
- encoding: UTF-8
49
- string: host2 response
50
- http_version: "1.1"
51
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
52
- recorded_with: VCR 2.0.0
53
- """
54
-
55
- Scenario Outline: Replay interaction that matches the host
56
- And a file named "host_matching.rb" with:
57
- """ruby
58
- include_http_adapter_for("<http_lib>")
59
-
60
- require 'vcr'
61
-
62
- VCR.configure do |c|
63
- <configuration>
64
- c.cassette_library_dir = 'cassettes'
65
- end
66
-
67
- VCR.use_cassette('example', :match_requests_on => [:host]) do
68
- puts "Response for host2: " + response_body_for(:get, "http://host2.com/home")
69
- end
70
-
71
- VCR.use_cassette('example', :match_requests_on => [:host]) do
72
- puts "Response for host1: " + response_body_for(:get, "http://host1.com/about")
73
- end
74
- """
75
- When I run `ruby host_matching.rb`
76
- Then it should pass with:
77
- """
78
- Response for host2: host2 response
79
- Response for host1: host1 response
80
- """
81
-
82
- Examples:
83
- | configuration | http_lib |
84
- | c.hook_into :fakeweb | net/http |
85
- | c.hook_into :webmock | net/http |
86
- | c.hook_into :webmock | httpclient |
87
- | c.hook_into :webmock | curb |
88
- | c.hook_into :webmock | patron |
89
- | c.hook_into :webmock | em-http-request |
90
- | c.hook_into :webmock | typhoeus |
91
- | c.hook_into :typhoeus | typhoeus |
92
- | c.hook_into :excon | excon |
93
- | c.hook_into :faraday | faraday (w/ net_http) |
94
- | c.hook_into :faraday | faraday (w/ typhoeus) |
95
-
@@ -1,89 +0,0 @@
1
- Feature: Identical requests are replayed in sequence
2
-
3
- When a cassette contains multiple HTTP interactions that match a request
4
- based on the configured `:match_requests_on` setting, the responses are
5
- sequenced: the first matching request will get the first response,
6
- the second matching request will get the second response, etc.
7
-
8
- Scenario Outline: identical requests are replayed in sequence
9
- Given a previously recorded cassette file "cassettes/example.yml" with:
10
- """
11
- ---
12
- http_interactions:
13
- - request:
14
- method: get
15
- uri: http://example.com/foo
16
- body:
17
- encoding: UTF-8
18
- string: ""
19
- headers: {}
20
- response:
21
- status:
22
- code: 200
23
- message: OK
24
- headers:
25
- Content-Length:
26
- - "10"
27
- body:
28
- encoding: UTF-8
29
- string: Response 1
30
- http_version: "1.1"
31
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
32
- - request:
33
- method: get
34
- uri: http://example.com/foo
35
- body:
36
- encoding: UTF-8
37
- string: ""
38
- headers: {}
39
- response:
40
- status:
41
- code: 200
42
- message: OK
43
- headers:
44
- Content-Length:
45
- - "10"
46
- body:
47
- encoding: UTF-8
48
- string: Response 2
49
- http_version: "1.1"
50
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
51
- recorded_with: VCR 2.0.0
52
- """
53
- And a file named "rotate_responses.rb" with:
54
- """ruby
55
- include_http_adapter_for("<http_lib>")
56
-
57
- require 'vcr'
58
-
59
- VCR.configure do |c|
60
- <configuration>
61
- c.cassette_library_dir = 'cassettes'
62
- end
63
-
64
- VCR.use_cassette('example') do
65
- puts response_body_for(:get, 'http://example.com/foo')
66
- puts response_body_for(:get, 'http://example.com/foo')
67
- end
68
- """
69
- When I run `ruby rotate_responses.rb`
70
- Then it should pass with:
71
- """
72
- Response 1
73
- Response 2
74
- """
75
-
76
- Examples:
77
- | configuration | http_lib |
78
- | c.hook_into :fakeweb | net/http |
79
- | c.hook_into :webmock | net/http |
80
- | c.hook_into :webmock | httpclient |
81
- | c.hook_into :webmock | curb |
82
- | c.hook_into :webmock | patron |
83
- | c.hook_into :webmock | em-http-request |
84
- | c.hook_into :webmock | typhoeus |
85
- | c.hook_into :typhoeus | typhoeus |
86
- | c.hook_into :excon | excon |
87
- | c.hook_into :faraday | faraday (w/ net_http) |
88
- | c.hook_into :faraday | faraday (w/ typhoeus) |
89
-
@@ -1,96 +0,0 @@
1
- Feature: Matching on Method
2
-
3
- Use the `:method` request matcher to match requests on the HTTP method
4
- (i.e. GET, POST, PUT, DELETE, etc). You will generally want to use
5
- this matcher.
6
-
7
- The `:method` matcher is used (along with the `:uri` matcher) by default
8
- if you do not specify how requests should match.
9
-
10
- Background:
11
- Given a previously recorded cassette file "cassettes/example.yml" with:
12
- """
13
- ---
14
- http_interactions:
15
- - request:
16
- method: post
17
- uri: http://post-request.com/
18
- body:
19
- encoding: UTF-8
20
- string: ""
21
- headers: {}
22
- response:
23
- status:
24
- code: 200
25
- message: OK
26
- headers:
27
- Content-Length:
28
- - "13"
29
- body:
30
- encoding: UTF-8
31
- string: post response
32
- http_version: "1.1"
33
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
34
- - request:
35
- method: get
36
- uri: http://get-request.com/
37
- body:
38
- encoding: UTF-8
39
- string: ""
40
- headers: {}
41
- response:
42
- status:
43
- code: 200
44
- message: OK
45
- headers:
46
- Content-Length:
47
- - "12"
48
- body:
49
- encoding: UTF-8
50
- string: get response
51
- http_version: "1.1"
52
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
53
- recorded_with: VCR 2.0.0
54
- """
55
-
56
- Scenario Outline: Replay interaction that matches the HTTP method
57
- And a file named "method_matching.rb" with:
58
- """ruby
59
- include_http_adapter_for("<http_lib>")
60
-
61
- require 'vcr'
62
-
63
- VCR.configure do |c|
64
- <configuration>
65
- c.cassette_library_dir = 'cassettes'
66
- end
67
-
68
- VCR.use_cassette('example', :match_requests_on => [:method]) do
69
- puts "Response for GET: " + response_body_for(:get, "http://example.com/")
70
- end
71
-
72
- VCR.use_cassette('example', :match_requests_on => [:method]) do
73
- puts "Response for POST: " + response_body_for(:post, "http://example.com/")
74
- end
75
- """
76
- When I run `ruby method_matching.rb`
77
- Then it should pass with:
78
- """
79
- Response for GET: get response
80
- Response for POST: post response
81
- """
82
-
83
- Examples:
84
- | configuration | http_lib |
85
- | c.hook_into :fakeweb | net/http |
86
- | c.hook_into :webmock | net/http |
87
- | c.hook_into :webmock | httpclient |
88
- | c.hook_into :webmock | curb |
89
- | c.hook_into :webmock | patron |
90
- | c.hook_into :webmock | em-http-request |
91
- | c.hook_into :webmock | typhoeus |
92
- | c.hook_into :typhoeus | typhoeus |
93
- | c.hook_into :excon | excon |
94
- | c.hook_into :faraday | faraday (w/ net_http) |
95
- | c.hook_into :faraday | faraday (w/ typhoeus) |
96
-
@@ -1,96 +0,0 @@
1
- Feature: Matching on Path
2
-
3
- Use the `:path` request matcher to match requests on the path portion
4
- of the request URI.
5
-
6
- You can use this (alone, or in combination with `:host`) as an
7
- alternative to `:uri` so that non-deterministic portions of the URI
8
- are not considered as part of the request matching.
9
-
10
- Background:
11
- Given a previously recorded cassette file "cassettes/example.yml" with:
12
- """
13
- ---
14
- http_interactions:
15
- - request:
16
- method: post
17
- uri: http://host1.com/about?date=2011-09-01
18
- body:
19
- encoding: UTF-8
20
- string: ""
21
- headers: {}
22
- response:
23
- status:
24
- code: 200
25
- message: OK
26
- headers:
27
- Content-Length:
28
- - "14"
29
- body:
30
- encoding: UTF-8
31
- string: about response
32
- http_version: "1.1"
33
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
34
- - request:
35
- method: post
36
- uri: http://host2.com/home?date=2011-09-01
37
- body:
38
- encoding: UTF-8
39
- string: ""
40
- headers: {}
41
- response:
42
- status:
43
- code: 200
44
- message: OK
45
- headers:
46
- Content-Length:
47
- - "15"
48
- body:
49
- encoding: UTF-8
50
- string: home response
51
- http_version: "1.1"
52
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
53
- recorded_with: VCR 2.0.0
54
- """
55
-
56
- Scenario Outline: Replay interaction that matches the path
57
- And a file named "path_matching.rb" with:
58
- """ruby
59
- include_http_adapter_for("<http_lib>")
60
-
61
- require 'vcr'
62
-
63
- VCR.configure do |c|
64
- <configuration>
65
- c.cassette_library_dir = 'cassettes'
66
- end
67
-
68
- VCR.use_cassette('example', :match_requests_on => [:path]) do
69
- puts "Response for /home: " + response_body_for(:get, "http://example.com/home")
70
- end
71
-
72
- VCR.use_cassette('example', :match_requests_on => [:path]) do
73
- puts "Response for /about: " + response_body_for(:get, "http://example.com/about")
74
- end
75
- """
76
- When I run `ruby path_matching.rb`
77
- Then it should pass with:
78
- """
79
- Response for /home: home response
80
- Response for /about: about response
81
- """
82
-
83
- Examples:
84
- | configuration | http_lib |
85
- | c.hook_into :fakeweb | net/http |
86
- | c.hook_into :webmock | net/http |
87
- | c.hook_into :webmock | httpclient |
88
- | c.hook_into :webmock | curb |
89
- | c.hook_into :webmock | patron |
90
- | c.hook_into :webmock | em-http-request |
91
- | c.hook_into :webmock | typhoeus |
92
- | c.hook_into :typhoeus | typhoeus |
93
- | c.hook_into :excon | excon |
94
- | c.hook_into :faraday | faraday (w/ net_http) |
95
- | c.hook_into :faraday | faraday (w/ typhoeus) |
96
-