vcr 3.0.2 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
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 +0,0 @@
1
- /Users/tony/src/vcr/CONTRIBUTING.md
@@ -1 +0,0 @@
1
- /Users/tony/src/vcr/LICENSE
@@ -1 +0,0 @@
1
- /Users/tony/src/vcr/README.md
@@ -1 +0,0 @@
1
- /Users/tony/src/vcr/Upgrade.md
@@ -1,18 +0,0 @@
1
- The cucumber features provided here demonstrate all of the major features of
2
- VCR. These features are executable documentation for VCR.
3
-
4
- Many of the examples use one (or both) of these helper functions
5
- provided by `spec/support/cucumber_helpers.rb`:
6
-
7
- * `start_sinatra_app`: starts a sinatra application on the given port.
8
- The server automatically shuts down when the ruby script ends. Many
9
- examples re-run the script without the sinatra server to demonstrate
10
- the replaying of a recorded HTTP response.
11
- * `include_http_adapter_for`: includes a module that implements a common
12
- HTTP interface for the given HTTP library. The `response_body_for`
13
- method will make an HTTP request using the given library. This
14
- allows scenarios to be run against each different supported HTTP
15
- library.
16
-
17
- If you have ideas to clarify or improve any of these cucumber features,
18
- please submit an [issue](https://github.com/vcr/vcr/issues) or pull request.
@@ -1,100 +0,0 @@
1
- Feature: Allow Unused HTTP Interactions
2
-
3
- If set to false, this cassette option will cause VCR to raise an error
4
- when a cassette is ejected and there are unused HTTP interactions remaining,
5
- unless there is already an exception unwinding the callstack.
6
-
7
- It verifies that all requests included in the cassette were made, and allows
8
- VCR to function a bit like a mock object at the HTTP layer.
9
-
10
- The option defaults to true (mostly for backwards compatibility).
11
-
12
- Background:
13
- Given a file named "vcr_config.rb" with:
14
- """ruby
15
- require 'vcr'
16
-
17
- VCR.configure do |c|
18
- c.hook_into :webmock
19
- c.cassette_library_dir = 'cassettes'
20
- end
21
- """
22
- And a previously recorded cassette file "cassettes/example.yml" with:
23
- """
24
- ---
25
- http_interactions:
26
- - request:
27
- method: get
28
- uri: http://example.com/foo
29
- body:
30
- encoding: UTF-8
31
- string: ""
32
- headers: {}
33
- response:
34
- status:
35
- code: 200
36
- message: OK
37
- headers:
38
- Content-Length:
39
- - "5"
40
- body:
41
- encoding: UTF-8
42
- string: Hello
43
- http_version: "1.1"
44
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
45
- recorded_with: VCR 2.0.0
46
- """
47
-
48
- Scenario: Unused HTTP interactions are allowed by default
49
- Given a file named "allowed_by_default.rb" with:
50
- """ruby
51
- require 'vcr_config'
52
-
53
- VCR.use_cassette("example") do
54
- # no requests
55
- end
56
- """
57
- When I run `ruby allowed_by_default.rb`
58
- Then it should pass
59
-
60
- Scenario: Error raised if option is false and there are unused interactions
61
- Given a file named "disallowed_with_no_requests.rb" with:
62
- """ruby
63
- require 'vcr_config'
64
-
65
- VCR.use_cassette("example", :allow_unused_http_interactions => false) do
66
- # no requests
67
- end
68
- """
69
- When I run `ruby disallowed_with_no_requests.rb`
70
- Then it should fail with an error like:
71
- """
72
- There are unused HTTP interactions left in the cassette:
73
- - [get http://example.com/foo] => [200 "Hello"]
74
- """
75
-
76
- Scenario: No error raised if option is false and all interactions are used
77
- Given a file named "disallowed_with_all_requests.rb" with:
78
- """ruby
79
- require 'vcr_config'
80
-
81
- VCR.use_cassette("example", :allow_unused_http_interactions => false) do
82
- Net::HTTP.get_response(URI("http://example.com/foo"))
83
- end
84
- """
85
- When I run `ruby disallowed_with_all_requests.rb`
86
- Then it should pass
87
-
88
- Scenario: Does not silence other errors raised in `use_cassette` block
89
- Given a file named "does_not_silence_other_errors.rb" with:
90
- """ruby
91
- require 'vcr_config'
92
-
93
- VCR.use_cassette("example", :allow_unused_http_interactions => false) do
94
- raise "boom"
95
- end
96
- """
97
- When I run `ruby does_not_silence_other_errors.rb`
98
- Then it should fail with "boom"
99
- And the output should not contain "There are unused HTTP interactions"
100
-
@@ -1,72 +0,0 @@
1
- Feature: Automatic Re-recording
2
-
3
- Over time, your cassettes may get out-of-date. APIs change and sites you
4
- scrape get updated. VCR provides a facility to automatically re-record your
5
- cassettes. Enable re-recording using the `:re_record_interval` option.
6
-
7
- The value provided should be an interval (expressed in seconds) that
8
- determines how often VCR will re-record the cassette. When a cassette
9
- is used, VCR checks the earliest `recorded_at` timestamp in the cassette;
10
- if more time than the interval has passed since that timestamp,
11
- VCR will use the `:all` record mode to cause it be re-recorded.
12
-
13
- Background:
14
- Given a previously recorded cassette file "cassettes/example.yml" with:
15
- """
16
- ---
17
- http_interactions:
18
- - request:
19
- method: get
20
- uri: http://localhost/
21
- body:
22
- encoding: UTF-8
23
- string: ""
24
- headers: {}
25
- response:
26
- status:
27
- code: 200
28
- message: OK
29
- headers:
30
- Content-Length:
31
- - "12"
32
- body:
33
- encoding: UTF-8
34
- string: Old Response
35
- http_version: "1.1"
36
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
37
- recorded_with: VCR 2.0.0
38
- """
39
- And a file named "re_record.rb" with:
40
- """ruby
41
- $server = start_sinatra_app do
42
- get('/') { 'New Response' }
43
- end
44
-
45
- require 'vcr'
46
-
47
- VCR.configure do |c|
48
- c.hook_into :webmock
49
- c.cassette_library_dir = 'cassettes'
50
- end
51
-
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
- end
55
- """
56
-
57
- Scenario: Cassette is not re-recorded when not enough time has passed
58
- Given it is Tue, 07 Nov 2011
59
- When I run `ruby re_record.rb`
60
- Then the output should contain "Old Response"
61
- But the output should not contain "New Response"
62
- And the file "cassettes/example.yml" should contain "Old Response"
63
- But the file "cassettes/example.yml" should not contain "New Response"
64
-
65
- Scenario: Cassette is re-recorded when enough time has passed
66
- Given it is Tue, 09 Nov 2011
67
- When I run `ruby re_record.rb`
68
- Then the output should contain "New Response"
69
- But the output should not contain "Old Response"
70
- And the file "cassettes/example.yml" should contain "New Response"
71
- But the file "cassettes/example.yml" should not contain "Old Response"
72
-
@@ -1,74 +0,0 @@
1
- Feature: Decode compressed response
2
-
3
- When the `:decode_compressed_response` option is set to a truthy value, VCR
4
- will decompress "gzip" and "deflate" response bodies before recording. This
5
- ensures that these interactions become readable and editable after being
6
- serialized.
7
-
8
- This option should be avoided if the actual decompression of response bodies
9
- is part of the functionality of the library or app being tested.
10
-
11
- Background:
12
- Given a file named "decompress.rb" with:
13
- """ruby
14
- require 'zlib'
15
- require 'stringio'
16
-
17
- $server = start_sinatra_app do
18
- get('/') {
19
- content = 'The quick brown fox jumps over the lazy dog'
20
- io = StringIO.new
21
-
22
- writer = Zlib::GzipWriter.new(io)
23
- writer << content
24
- writer.close
25
-
26
- headers['Content-Encoding'] = 'gzip'
27
- io.string
28
- }
29
- end
30
-
31
- require 'vcr'
32
-
33
- VCR.configure do |c|
34
- c.cassette_library_dir = 'cassettes'
35
- c.hook_into :webmock
36
- c.default_cassette_options = { :serialize_with => :syck }
37
- end
38
- """
39
-
40
- Scenario: The option is not set by default
41
- When I append to file "decompress.rb":
42
- """ruby
43
- VCR.use_cassette(:decompress) do
44
- Net::HTTP.start('localhost', $server.port) do |http|
45
- http.get('/', 'accept-encoding' => 'identity')
46
- end
47
- end
48
- """
49
- And I run `ruby decompress.rb`
50
- Then the file "cassettes/decompress.yml" should contain a YAML fragment like:
51
- """
52
- Content-Encoding:
53
- - gzip
54
- """
55
-
56
- Scenario: The option is enabled
57
- When I append to file "decompress.rb":
58
- """ruby
59
- VCR.use_cassette(:decompress, :decode_compressed_response => true) do
60
- Net::HTTP.start('localhost', $server.port) do |http|
61
- http.get('/', 'accept-encoding' => 'identity')
62
- end
63
- end
64
- """
65
- And I run `ruby decompress.rb`
66
- Then the file "cassettes/decompress.yml" should contain a YAML fragment like:
67
- """
68
- Content-Length:
69
- - '43'
70
- """
71
- And the file "cassettes/decompress.yml" should contain:
72
- """
73
- string: The quick brown fox jumps over the lazy dog
74
- """
@@ -1,100 +0,0 @@
1
- Feature: Dynamic ERB cassettes
2
-
3
- By default, cassettes are static: the exact response that was received
4
- when the cassette was recorded will be replayed for all future requests.
5
- Usually, this is fine, but in some cases you need something more dynamic.
6
- You can use ERB for this.
7
-
8
- To enable ERB evaluation of a cassette, pass the `:erb => true` option
9
- to a cassette. If you want to pass variables to the cassette, you can
10
- pass the names and values of the variables in a hash (`:erb => { ... }`).
11
-
12
- Scenario: Enable dynamic ERB cassette evalutation using :erb => true
13
- Given a previously recorded cassette file "cassettes/dynamic.yml" with:
14
- """
15
- ---
16
- http_interactions:
17
- - request:
18
- method: get
19
- uri: http://example.com/foo?a=<%= 'b' * 3 %>
20
- body:
21
- encoding: UTF-8
22
- string: ''
23
- headers: {}
24
- response:
25
- status:
26
- code: 200
27
- message: OK
28
- headers:
29
- Content-Type:
30
- - text/html;charset=utf-8
31
- Content-Length:
32
- - '9'
33
- body:
34
- encoding: UTF-8
35
- string: Hello <%= 'bar'.next %>
36
- http_version: '1.1'
37
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
38
- recorded_with: VCR 2.0.0
39
- """
40
- And a file named "dynamic_erb_example.rb" with:
41
- """ruby
42
- require 'vcr'
43
-
44
- VCR.configure do |c|
45
- c.hook_into :webmock
46
- c.cassette_library_dir = 'cassettes'
47
- end
48
-
49
- VCR.use_cassette('dynamic', :erb => true) do
50
- response = Net::HTTP.get_response('example.com', '/foo?a=bbb')
51
- puts "Response: #{response.body}"
52
- end
53
- """
54
- When I run `ruby dynamic_erb_example.rb`
55
- Then it should pass with "Response: Hello bas"
56
-
57
- Scenario: Pass arguments to the ERB using :erb => { ... }
58
- Given a previously recorded cassette file "cassettes/dynamic.yml" with:
59
- """
60
- ---
61
- http_interactions:
62
- - request:
63
- method: get
64
- uri: http://example.com/foo?a=<%= arg1 %>
65
- body:
66
- encoding: UTF-8
67
- string: ''
68
- headers: {}
69
- response:
70
- status:
71
- code: 200
72
- message: OK
73
- headers:
74
- Content-Type:
75
- - text/html;charset=utf-8
76
- Content-Length:
77
- - '9'
78
- body:
79
- encoding: UTF-8
80
- string: Hello <%= arg2 %>
81
- http_version: '1.1'
82
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
83
- recorded_with: VCR 2.0.0
84
- """
85
- And a file named "dynamic_erb_example.rb" with:
86
- """ruby
87
- require 'vcr'
88
-
89
- VCR.configure do |c|
90
- c.hook_into :webmock
91
- c.cassette_library_dir = 'cassettes'
92
- end
93
-
94
- VCR.use_cassette('dynamic', :erb => { :arg1 => 7, :arg2 => 'baz' }) do
95
- response = Net::HTTP.get_response('example.com', '/foo?a=7')
96
- puts "Response: #{response.body}"
97
- end
98
- """
99
- When I run `ruby dynamic_erb_example.rb`
100
- Then it should pass with "Response: Hello baz"
@@ -1,126 +0,0 @@
1
- Feature: exclusive cassette
2
-
3
- VCR allows cassettes to be nested. This is particularly useful in
4
- a context like cucumber, where you may be using a cassette for an
5
- entire scenario, and also using a cassette within a particular step
6
- definition.
7
-
8
- By default, both the inner and outer cassettes are active. On each
9
- request, VCR will look for a matching HTTP interaction in the inner
10
- cassette, and it will use the outer cassette as a fall back if none
11
- can be found.
12
-
13
- If you do not want the HTTP interactions of the outer cassette considered,
14
- you can pass the `:exclusive` option, so that the inner cassette is
15
- used exclusively.
16
-
17
- Background:
18
- Given a previously recorded cassette file "cassettes/outer.yml" with:
19
- """
20
- ---
21
- http_interactions:
22
- - request:
23
- method: get
24
- uri: http://localhost/outer
25
- body:
26
- encoding: UTF-8
27
- string: ""
28
- headers: {}
29
- response:
30
- status:
31
- code: 200
32
- message: OK
33
- headers:
34
- Content-Length:
35
- - "18"
36
- body:
37
- encoding: UTF-8
38
- string: Old outer response
39
- http_version: "1.1"
40
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
41
- recorded_with: VCR 2.0.0
42
- """
43
- And a previously recorded cassette file "cassettes/inner.yml" with:
44
- """
45
- ---
46
- http_interactions:
47
- - request:
48
- method: get
49
- uri: http://localhost/inner
50
- body:
51
- encoding: UTF-8
52
- string: ""
53
- headers: {}
54
- response:
55
- status:
56
- code: 200
57
- message: OK
58
- headers:
59
- Content-Length:
60
- - "18"
61
- body:
62
- encoding: UTF-8
63
- string: Old inner response
64
- http_version: "1.1"
65
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
66
- recorded_with: VCR 2.0.0
67
- """
68
- And a file named "setup.rb" with:
69
- """ruby
70
- include_http_adapter_for("net/http")
71
-
72
- $server = start_sinatra_app do
73
- get('/:path') { "New #{params[:path]} response" }
74
- end
75
-
76
- require 'vcr'
77
-
78
- VCR.configure do |c|
79
- c.hook_into :webmock
80
- c.cassette_library_dir = 'cassettes'
81
- c.default_cassette_options = {
82
- :record => :new_episodes,
83
- :match_requests_on => [:method, :host, :path]
84
- }
85
- end
86
- """
87
-
88
- Scenario: Cassettes are not exclusive by default
89
- Given a file named "not_exclusive.rb" with:
90
- """ruby
91
- require 'setup'
92
-
93
- VCR.use_cassette('outer') do
94
- VCR.use_cassette('inner') do
95
- puts response_body_for(:get, "http://localhost:#{$server.port}/outer")
96
- puts response_body_for(:get, "http://localhost:#{$server.port}/inner")
97
- end
98
- end
99
- """
100
- When I run `ruby not_exclusive.rb`
101
- Then it should pass with:
102
- """
103
- Old outer response
104
- Old inner response
105
- """
106
-
107
- Scenario: Use an exclusive cassette
108
- Given a file named "exclusive.rb" with:
109
- """ruby
110
- require 'setup'
111
-
112
- VCR.use_cassette('outer') do
113
- VCR.use_cassette('inner', :exclusive => true) do
114
- puts response_body_for(:get, "http://localhost:#{$server.port}/outer")
115
- puts response_body_for(:get, "http://localhost:#{$server.port}/inner")
116
- end
117
- end
118
- """
119
- When I run `ruby exclusive.rb`
120
- Then it should pass with:
121
- """
122
- New outer response
123
- Old inner response
124
- """
125
- And the file "cassettes/inner.yml" should contain "New outer response"
126
-