vcr 3.0.3 → 4.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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vcr.rb +18 -1
  3. data/lib/vcr/cassette.rb +11 -3
  4. data/lib/vcr/cassette/persisters/file_system.rb +1 -1
  5. data/lib/vcr/configuration.rb +3 -5
  6. data/lib/vcr/deprecations.rb +0 -62
  7. data/lib/vcr/errors.rb +16 -0
  8. data/lib/vcr/library_hooks/typhoeus.rb +37 -8
  9. data/lib/vcr/middleware/faraday.rb +5 -1
  10. data/lib/vcr/structs.rb +1 -1
  11. data/lib/vcr/util/hooks.rb +1 -0
  12. data/lib/vcr/version.rb +1 -1
  13. metadata +9 -249
  14. data/features/CHANGELOG.md +0 -710
  15. data/features/CONTRIBUTING.md +0 -26
  16. data/features/LICENSE.md +0 -20
  17. data/features/README.md +0 -339
  18. data/features/Upgrade.md +0 -289
  19. data/features/about_these_examples.md +0 -18
  20. data/features/cassettes/allow_unused_http_interactions.feature +0 -100
  21. data/features/cassettes/automatic_re_recording.feature +0 -72
  22. data/features/cassettes/decompress.feature +0 -74
  23. data/features/cassettes/dynamic_erb.feature +0 -100
  24. data/features/cassettes/exclusive.feature +0 -126
  25. data/features/cassettes/format.feature +0 -411
  26. data/features/cassettes/freezing_time.feature +0 -68
  27. data/features/cassettes/naming.feature +0 -28
  28. data/features/cassettes/no_cassette.feature +0 -152
  29. data/features/cassettes/update_content_length_header.feature +0 -112
  30. data/features/configuration/allow_http_connections_when_no_cassette.feature +0 -55
  31. data/features/configuration/cassette_library_dir.feature +0 -31
  32. data/features/configuration/debug_logging.feature +0 -58
  33. data/features/configuration/default_cassette_options.feature +0 -100
  34. data/features/configuration/filter_sensitive_data.feature +0 -153
  35. data/features/configuration/hook_into.feature +0 -172
  36. data/features/configuration/ignore_request.feature +0 -192
  37. data/features/configuration/preserve_exact_body_bytes.feature +0 -108
  38. data/features/configuration/query_parser.feature +0 -84
  39. data/features/configuration/uri_parser.feature +0 -93
  40. data/features/getting_started.md +0 -82
  41. data/features/hooks/after_http_request.feature +0 -58
  42. data/features/hooks/around_http_request.feature +0 -57
  43. data/features/hooks/before_http_request.feature +0 -63
  44. data/features/hooks/before_playback.feature +0 -184
  45. data/features/hooks/before_record.feature +0 -172
  46. data/features/http_libraries/em_http_request.feature +0 -250
  47. data/features/http_libraries/net_http.feature +0 -179
  48. data/features/middleware/faraday.feature +0 -56
  49. data/features/middleware/rack.feature +0 -92
  50. data/features/record_modes/all.feature +0 -82
  51. data/features/record_modes/new_episodes.feature +0 -79
  52. data/features/record_modes/none.feature +0 -72
  53. data/features/record_modes/once.feature +0 -95
  54. data/features/request_matching/README.md +0 -30
  55. data/features/request_matching/body.feature +0 -91
  56. data/features/request_matching/body_as_json.feature +0 -90
  57. data/features/request_matching/custom_matcher.feature +0 -135
  58. data/features/request_matching/headers.feature +0 -85
  59. data/features/request_matching/host.feature +0 -95
  60. data/features/request_matching/identical_request_sequence.feature +0 -89
  61. data/features/request_matching/method.feature +0 -96
  62. data/features/request_matching/path.feature +0 -96
  63. data/features/request_matching/playback_repeats.feature +0 -98
  64. data/features/request_matching/query.feature +0 -97
  65. data/features/request_matching/uri.feature +0 -94
  66. data/features/request_matching/uri_without_param.feature +0 -101
  67. data/features/step_definitions/cli_steps.rb +0 -199
  68. data/features/support/env.rb +0 -46
  69. data/features/support/http_lib_filters.rb +0 -46
  70. data/features/test_frameworks/cucumber.feature +0 -211
  71. data/features/test_frameworks/rspec_macro.feature +0 -81
  72. data/features/test_frameworks/rspec_metadata.feature +0 -150
  73. data/features/test_frameworks/test_unit.feature +0 -49
  74. data/lib/vcr/extensions/net_http_response.rb +0 -36
  75. data/lib/vcr/library_hooks/fakeweb.rb +0 -197
  76. data/spec/acceptance/concurrency_spec.rb +0 -51
  77. data/spec/acceptance/threading_spec.rb +0 -34
  78. data/spec/fixtures/cassette_spec/1_x_cassette.yml +0 -110
  79. data/spec/fixtures/cassette_spec/empty.yml +0 -0
  80. data/spec/fixtures/cassette_spec/example.yml +0 -111
  81. data/spec/fixtures/cassette_spec/with_localhost_requests.yml +0 -111
  82. data/spec/fixtures/fake_example_responses.yml +0 -110
  83. data/spec/fixtures/match_requests_on.yml +0 -187
  84. data/spec/lib/vcr/cassette/erb_renderer_spec.rb +0 -53
  85. data/spec/lib/vcr/cassette/http_interaction_list_spec.rb +0 -295
  86. data/spec/lib/vcr/cassette/migrator_spec.rb +0 -196
  87. data/spec/lib/vcr/cassette/persisters/file_system_spec.rb +0 -75
  88. data/spec/lib/vcr/cassette/persisters_spec.rb +0 -39
  89. data/spec/lib/vcr/cassette/serializers_spec.rb +0 -182
  90. data/spec/lib/vcr/cassette_spec.rb +0 -618
  91. data/spec/lib/vcr/configuration_spec.rb +0 -326
  92. data/spec/lib/vcr/deprecations_spec.rb +0 -85
  93. data/spec/lib/vcr/errors_spec.rb +0 -178
  94. data/spec/lib/vcr/extensions/net_http_response_spec.rb +0 -86
  95. data/spec/lib/vcr/library_hooks/excon_spec.rb +0 -104
  96. data/spec/lib/vcr/library_hooks/fakeweb_spec.rb +0 -169
  97. data/spec/lib/vcr/library_hooks/faraday_spec.rb +0 -68
  98. data/spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb +0 -36
  99. data/spec/lib/vcr/library_hooks/typhoeus_spec.rb +0 -162
  100. data/spec/lib/vcr/library_hooks/webmock_spec.rb +0 -117
  101. data/spec/lib/vcr/library_hooks_spec.rb +0 -51
  102. data/spec/lib/vcr/middleware/faraday_spec.rb +0 -181
  103. data/spec/lib/vcr/middleware/rack_spec.rb +0 -115
  104. data/spec/lib/vcr/request_ignorer_spec.rb +0 -70
  105. data/spec/lib/vcr/request_matcher_registry_spec.rb +0 -345
  106. data/spec/lib/vcr/structs_spec.rb +0 -732
  107. data/spec/lib/vcr/test_frameworks/cucumber_spec.rb +0 -107
  108. data/spec/lib/vcr/test_frameworks/rspec_spec.rb +0 -94
  109. data/spec/lib/vcr/util/hooks_spec.rb +0 -158
  110. data/spec/lib/vcr/util/internet_connection_spec.rb +0 -37
  111. data/spec/lib/vcr/util/version_checker_spec.rb +0 -31
  112. data/spec/lib/vcr/version_spec.rb +0 -27
  113. data/spec/lib/vcr_spec.rb +0 -354
  114. data/spec/monkey_patches.rb +0 -186
  115. data/spec/spec_helper.rb +0 -63
  116. data/spec/support/configuration_stubbing.rb +0 -8
  117. data/spec/support/cucumber_helpers.rb +0 -39
  118. data/spec/support/fixnum_extension.rb +0 -10
  119. data/spec/support/http_library_adapters.rb +0 -289
  120. data/spec/support/limited_uri.rb +0 -21
  121. data/spec/support/ruby_interpreter.rb +0 -7
  122. data/spec/support/shared_example_groups/excon.rb +0 -63
  123. data/spec/support/shared_example_groups/hook_into_http_library.rb +0 -594
  124. data/spec/support/shared_example_groups/request_hooks.rb +0 -59
  125. data/spec/support/sinatra_app.rb +0 -86
  126. data/spec/support/vcr_localhost_server.rb +0 -76
  127. data/spec/support/vcr_stub_helpers.rb +0 -17
@@ -1,28 +0,0 @@
1
- Feature: Naming
2
-
3
- When inserting or using a cassette, the first argument is the cassette name.
4
- You can use any string for the name. If you use the default `:file_system`
5
- storage backend, VCR will sanitize the string before using it as a file name,
6
- so that it is a file-system friendly file name.
7
-
8
- Scenario: Name sanitizing
9
- Given a file named "name_sanitizing.rb" with:
10
- """ruby
11
- $server = start_sinatra_app do
12
- get('/') { "Hello" }
13
- end
14
-
15
- require 'vcr'
16
-
17
- VCR.configure do |c|
18
- c.cassette_library_dir = 'cassettes'
19
- c.hook_into :webmock
20
- end
21
-
22
- VCR.use_cassette('Fee, Fi Fo Fum') do
23
- Net::HTTP.get_response('localhost', '/', $server.port)
24
- end
25
- """
26
- And the directory "cassettes" does not exist
27
- When I run `ruby name_sanitizing.rb`
28
- Then the file "cassettes/Fee_Fi_Fo_Fum.yml" should contain "Hello"
@@ -1,152 +0,0 @@
1
- Feature: Error for HTTP request made when no cassette is in use
2
-
3
- VCR is designed to help you remove all HTTP dependencies from your
4
- test suite. To assist with this, VCR will cause an exception to be
5
- raised when an HTTP request is made while there is no cassette in
6
- use. The error is helpful to pinpoint where HTTP requests are
7
- made so you can use a VCR cassette at that point in your code.
8
-
9
- If you want insight about how VCR attempted to handle the request,
10
- you can use the [debug\_logger](../configuration/debug-logging)
11
- configuration option to log more details.
12
-
13
- If you want to allow an HTTP request to proceed as normal, you can
14
- set the [allow\_http\_connections\_when\_no\_cassette](../configuration/allow-http-connections-when-no-cassette)
15
- configuration option or you can temporarily turn VCR off:
16
-
17
- - `VCR.turn_off!` => turn VCR off so HTTP requests are allowed.
18
- Cassette insertions will trigger an error.
19
- - `VCR.turn_off!(:ignore_cassettes => true)` => turn
20
- VCR off and ignore cassette insertions (so that no error is raised).
21
- - `VCR.turn_on!` => turn VCR back on
22
- - `VCR.turned_off { ... }` => turn VCR off for the duration of the
23
- provided block.
24
-
25
- @exclude-jruby
26
- Scenario Outline: Error for request when no cassette is in use
27
- Given a file named "no_cassette_error.rb" with:
28
- """ruby
29
- include_http_adapter_for("<http_lib>")
30
-
31
- require 'vcr'
32
-
33
- VCR.configure do |c|
34
- <configuration>
35
- c.cassette_library_dir = 'cassettes'
36
- end
37
-
38
- response_body_for(:get, 'http://example.com/')
39
- """
40
- When I run `ruby no_cassette_error.rb`
41
- Then it should fail with "An HTTP request has been made that VCR does not know how to handle"
42
-
43
- Examples:
44
- | configuration | http_lib |
45
- | c.hook_into :fakeweb | net/http |
46
- | c.hook_into :webmock | net/http |
47
- | c.hook_into :webmock | httpclient |
48
- | c.hook_into :webmock | curb |
49
- | c.hook_into :webmock | patron |
50
- | c.hook_into :webmock | em-http-request |
51
- | c.hook_into :webmock | typhoeus |
52
- | c.hook_into :typhoeus | typhoeus |
53
- | c.hook_into :excon | excon |
54
- | c.hook_into :faraday | faraday (w/ net_http) |
55
-
56
- Scenario: Temporarily turn VCR off to allow HTTP requests to procede as normal
57
- Given a file named "turn_off_vcr.rb" with:
58
- """ruby
59
- $server = start_sinatra_app do
60
- get('/') { 'Hello' }
61
- end
62
-
63
- require 'vcr'
64
-
65
- VCR.configure do |c|
66
- c.hook_into :webmock
67
- end
68
- WebMock.allow_net_connect!
69
-
70
- def make_request(context)
71
- puts context
72
- puts Net::HTTP.get_response('localhost', '/', $server.port).body
73
- rescue => e
74
- puts "Error: #{e.class}"
75
- end
76
-
77
- VCR.turned_off do
78
- make_request "In VCR.turned_off block"
79
- end
80
-
81
- make_request "Outside of VCR.turned_off block"
82
-
83
- VCR.turn_off!
84
- make_request "After calling VCR.turn_off!"
85
-
86
- VCR.turn_on!
87
- make_request "After calling VCR.turn_on!"
88
- """
89
- When I run `ruby turn_off_vcr.rb`
90
- Then the output should contain:
91
- """
92
- In VCR.turned_off block
93
- Hello
94
- """
95
- And the output should contain:
96
- """
97
- Outside of VCR.turned_off block
98
- Error: VCR::Errors::UnhandledHTTPRequestError
99
- """
100
- And the output should contain:
101
- """
102
- After calling VCR.turn_off!
103
- Hello
104
- """
105
- And the output should contain:
106
- """
107
- After calling VCR.turn_on!
108
- Error: VCR::Errors::UnhandledHTTPRequestError
109
- """
110
-
111
- Scenario: Turning VCR off prevents cassettes from being inserted
112
- Given a file named "turn_off_vcr_and_insert_cassette.rb" with:
113
- """ruby
114
- require 'vcr'
115
-
116
- VCR.configure do |c|
117
- c.hook_into :webmock
118
- end
119
- WebMock.allow_net_connect!
120
-
121
- VCR.turn_off!
122
- VCR.insert_cassette('example')
123
- """
124
- When I run `ruby turn_off_vcr_and_insert_cassette.rb`
125
- Then it should fail with "VCR is turned off. You must turn it on before you can insert a cassette."
126
-
127
- Scenario: Turning VCR off with `:ignore_cassettes => true` ignores cassettes
128
- Given a file named "turn_off_vcr_and_insert_cassette.rb" with:
129
- """ruby
130
- $server = start_sinatra_app do
131
- get('/') { 'Hello' }
132
- end
133
-
134
- require 'vcr'
135
-
136
- VCR.configure do |c|
137
- c.cassette_library_dir = 'cassettes'
138
- c.hook_into :webmock
139
- end
140
- WebMock.allow_net_connect!
141
-
142
- VCR.turn_off!(:ignore_cassettes => true)
143
-
144
- VCR.use_cassette('example') do
145
- response = Net::HTTP.get_response('localhost', '/', $server.port).body
146
- puts "Response: #{response}"
147
- end
148
- """
149
- When I run `ruby turn_off_vcr_and_insert_cassette.rb`
150
- Then it should pass with "Response: Hello"
151
- And the file "cassettes/example.yml" should not exist
152
-
@@ -1,112 +0,0 @@
1
- Feature: Update content_length header
2
-
3
- When the `:update_content_length_header` option is set to a truthy value,
4
- VCR will ensure that the `Content-Length` header will have the correct
5
- value. This is useful in several situations:
6
-
7
- - When you manually edit the cassette file and change the resonse body
8
- length. You can use this option so you don't have to manually calculate
9
- and update the body length.
10
- - When you use ERB, the response body length may vary. This will ensure
11
- it is always correct.
12
- - Syck, the default YAML engine for ruby 1.8 (and 1.9, unless you compile
13
- it to use Psych), has a bug where it sometimes will remove some
14
- whitespace strings when you serialize them. This may cause the
15
- `Content-Length` header to have the wrong value.
16
-
17
- This is especially important when you use a client that checks the
18
- `Content-Length` header. Mechanize, for example, will raise an `EOFError`
19
- when the header value does not match the actual body length.
20
-
21
- Background:
22
- Given a previously recorded cassette file "cassettes/example.yml" with:
23
- """
24
- ---
25
- http_interactions:
26
- - request:
27
- method: get
28
- uri: http://example.com/
29
- body:
30
- encoding: UTF-8
31
- string: ""
32
- headers: {}
33
- response:
34
- status:
35
- code: 200
36
- message: OK
37
- headers:
38
- Content-Type:
39
- - text/html;charset=utf-8
40
- Content-Length:
41
- - "11"
42
- body:
43
- encoding: UTF-8
44
- string: Hello <modified>
45
- http_version: "1.1"
46
- recorded_at: Tue, 01 Nov 2011 04:58:44 GMT
47
- recorded_with: VCR 2.0.0
48
- """
49
- And a file named "common_stuff.rb" with:
50
- """ruby
51
- require 'vcr'
52
-
53
- VCR.configure do |c|
54
- c.cassette_library_dir = 'cassettes'
55
- c.hook_into :webmock
56
- end
57
-
58
- def make_request_and_print_results
59
- response = Net::HTTP.get_response('example.com', '/')
60
- puts "Body length: #{response.body.length}"
61
- puts "Header value: #{response['Content-Length']}"
62
- end
63
- """
64
-
65
- Scenario: Default :update_content_length_header setting
66
- Given a file named "default.rb" with:
67
- """ruby
68
- require 'common_stuff'
69
-
70
- VCR.use_cassette('example') do
71
- make_request_and_print_results
72
- end
73
- """
74
- When I run `ruby default.rb`
75
- Then the output should contain:
76
- """
77
- Body length: 16
78
- Header value: 11
79
- """
80
-
81
- Scenario: :update_content_length_header => false
82
- Given a file named "false.rb" with:
83
- """ruby
84
- require 'common_stuff'
85
-
86
- VCR.use_cassette('example', :update_content_length_header => false) do
87
- make_request_and_print_results
88
- end
89
- """
90
- When I run `ruby false.rb`
91
- Then the output should contain:
92
- """
93
- Body length: 16
94
- Header value: 11
95
- """
96
-
97
- Scenario: :update_content_length_header => true
98
- Given a file named "true.rb" with:
99
- """ruby
100
- require 'common_stuff'
101
-
102
- VCR.use_cassette('example', :update_content_length_header => true) do
103
- make_request_and_print_results
104
- end
105
- """
106
- When I run `ruby true.rb`
107
- Then the output should contain:
108
- """
109
- Body length: 16
110
- Header value: 16
111
- """
112
-
@@ -1,55 +0,0 @@
1
- Feature: Allow HTTP connections when no cassette
2
-
3
- Usually, HTTP requests made when no cassette is inserted will [result in an
4
- error](../cassettes/error-for-http-request-made-when-no-cassette-is-in-use).
5
- You can set the `allow_http_connections_when_no_cassette` configuration option
6
- to true to allow requests, if you do not want to use VCR for everything.
7
-
8
- Background:
9
- Given a file named "vcr_setup.rb" with:
10
- """ruby
11
- if ARGV.include?('--with-server')
12
- $server = start_sinatra_app do
13
- get('/') { "Hello" }
14
- end
15
- end
16
-
17
- require 'vcr'
18
-
19
- VCR.configure do |c|
20
- c.allow_http_connections_when_no_cassette = true
21
- c.hook_into :webmock
22
- c.cassette_library_dir = 'cassettes'
23
- c.default_cassette_options = {
24
- :match_requests_on => [:method, :host, :path]
25
- }
26
- end
27
- """
28
- And the directory "vcr/cassettes" does not exist
29
-
30
- Scenario: Allow HTTP connections when no cassette
31
- Given a file named "no_cassette.rb" with:
32
- """ruby
33
- require 'vcr_setup.rb'
34
-
35
- puts "Response: " + Net::HTTP.get_response('localhost', '/', $server ? $server.port : 0).body
36
- """
37
- When I run `ruby no_cassette.rb --with-server`
38
- Then the output should contain "Response: Hello"
39
-
40
- Scenario: Cassettes record and replay as normal
41
- Given a file named "record_replay_cassette.rb" with:
42
- """ruby
43
- require 'vcr_setup.rb'
44
-
45
- VCR.use_cassette('localhost') do
46
- puts "Response: " + Net::HTTP.get_response('localhost', '/', $server ? $server.port : 0).body
47
- end
48
- """
49
- When I run `ruby record_replay_cassette.rb --with-server`
50
- Then the output should contain "Response: Hello"
51
- And the file "cassettes/localhost.yml" should contain "Hello"
52
-
53
- When I run `ruby record_replay_cassette.rb`
54
- Then the output should contain "Response: Hello"
55
-
@@ -1,31 +0,0 @@
1
- Feature: cassette_library_dir
2
-
3
- The `cassette_library_dir` configuration option sets a directory
4
- where VCR saves each cassette.
5
-
6
- Note: When using Rails, avoid using the `test/fixtures` directory
7
- to store the cassettes. Rails treats any YAML file in the fixtures
8
- directory as an ActiveRecord fixture.
9
- This will cause an `ActiveRecord::Fixture::FormatError` to be raised.
10
-
11
- Scenario: cassette_library_dir
12
- Given a file named "cassette_library_dir.rb" with:
13
- """ruby
14
- $server = start_sinatra_app do
15
- get('/') { "Hello" }
16
- end
17
-
18
- require 'vcr'
19
-
20
- VCR.configure do |c|
21
- c.cassette_library_dir = 'vcr/cassettes'
22
- c.hook_into :webmock
23
- end
24
-
25
- VCR.use_cassette('localhost') do
26
- Net::HTTP.get_response('localhost', '/', $server.port)
27
- end
28
- """
29
- And the directory "vcr/cassettes" does not exist
30
- When I run `ruby cassette_library_dir.rb`
31
- Then the file "vcr/cassettes/localhost.yml" should exist
@@ -1,58 +0,0 @@
1
- Feature: Debug Logging
2
-
3
- Use the `debug_logger` option to set an IO-like object that VCR will log
4
- debug output to. This is a useful way to troubleshoot what VCR is doing.
5
-
6
- The debug logger must respond to `#puts`.
7
-
8
- Scenario: Use the debug logger for troubleshooting
9
- Given a file named "debug_logger.rb" with:
10
- """ruby
11
- if ARGV.include?('--with-server')
12
- $server = start_sinatra_app do
13
- get('/') { "Hello World" }
14
- end
15
- end
16
-
17
- require 'vcr'
18
-
19
- VCR.configure do |c|
20
- c.hook_into :webmock
21
- c.cassette_library_dir = 'cassettes'
22
- c.debug_logger = File.open(ARGV.first, 'w')
23
- c.default_cassette_options = {
24
- :match_requests_on => [:method, :host, :path]
25
- }
26
- end
27
-
28
- VCR.use_cassette('example') do
29
- port = $server ? $server.port : 7777
30
- Net::HTTP.get_response(URI("http://localhost:#{port}/"))
31
- end
32
- """
33
- When I run `ruby debug_logger.rb record.log --with-server`
34
- Given that port numbers in "record.log" are normalized to "7777"
35
- Then the file "record.log" should contain exactly:
36
- """
37
- [Cassette: 'example'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :host, :path], :allow_unused_http_interactions=>true, :serialize_with=>:yaml, :persist_with=>:file_system}
38
- [webmock] Handling request: [get http://localhost:7777/] (disabled: false)
39
- [Cassette: 'example'] Initialized HTTPInteractionList with request matchers [:method, :host, :path] and 0 interaction(s): { }
40
- [webmock] Identified request type (recordable) for [get http://localhost:7777/]
41
- [Cassette: 'example'] Recorded HTTP interaction [get http://localhost:7777/] => [200 "Hello World"]
42
-
43
- """
44
- When I run `ruby debug_logger.rb playback.log`
45
- Given that port numbers in "playback.log" are normalized to "7777"
46
- Then the file "playback.log" should contain exactly:
47
- """
48
- [Cassette: 'example'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :host, :path], :allow_unused_http_interactions=>true, :serialize_with=>:yaml, :persist_with=>:file_system}
49
- [webmock] Handling request: [get http://localhost:7777/] (disabled: false)
50
- [Cassette: 'example'] Initialized HTTPInteractionList with request matchers [:method, :host, :path] and 1 interaction(s): { [get http://localhost:7777/] => [200 "Hello World"] }
51
- [Cassette: 'example'] Checking if [get http://localhost:7777/] matches [get http://localhost:7777/] using [:method, :host, :path]
52
- [Cassette: 'example'] method (matched): current request [get http://localhost:7777/] vs [get http://localhost:7777/]
53
- [Cassette: 'example'] host (matched): current request [get http://localhost:7777/] vs [get http://localhost:7777/]
54
- [Cassette: 'example'] path (matched): current request [get http://localhost:7777/] vs [get http://localhost:7777/]
55
- [Cassette: 'example'] Found matching interaction for [get http://localhost:7777/] at index 0: [200 "Hello World"]
56
- [webmock] Identified request type (stubbed_by_vcr) for [get http://localhost:7777/]
57
-
58
- """
@@ -1,100 +0,0 @@
1
- Feature: default_cassette_options
2
-
3
- The `default_cassette_options` configuration option takes a hash
4
- that provides defaults for each cassette you use. Any cassette
5
- can override the defaults as well as set additional options.
6
-
7
- The `:match_requests_on` option defaults to `[:method, :uri]` when
8
- it has not been set.
9
-
10
- The `:record` option defaults to `:once` when it has not been set.
11
-
12
- Background:
13
- Given a file named "vcr_setup.rb" with:
14
- """ruby
15
- require 'vcr'
16
-
17
- VCR.configure do |c|
18
- c.default_cassette_options = { :record => :new_episodes, :erb => true }
19
-
20
- # not important for this example, but must be set to something
21
- c.hook_into :webmock
22
- c.cassette_library_dir = 'cassettes'
23
- end
24
- """
25
-
26
- Scenario: cassettes get default values from configured `default_cassette_options`
27
- Given a file named "default_cassette_options.rb" with:
28
- """ruby
29
- require 'vcr_setup.rb'
30
-
31
- VCR.use_cassette('example') do
32
- puts "Record Mode: #{VCR.current_cassette.record_mode}"
33
- puts "ERB: #{VCR.current_cassette.erb}"
34
- end
35
- """
36
- When I run `ruby default_cassette_options.rb`
37
- Then the output should contain:
38
- """
39
- Record Mode: new_episodes
40
- ERB: true
41
- """
42
-
43
- Scenario: `:match_requests_on` defaults to `[:method, :uri]` when it has not been set
44
- Given a file named "default_cassette_options.rb" with:
45
- """ruby
46
- require 'vcr_setup.rb'
47
-
48
- VCR.use_cassette('example') do
49
- puts "Match Requests On: #{VCR.current_cassette.match_requests_on.inspect}"
50
- end
51
- """
52
- When I run `ruby default_cassette_options.rb`
53
- Then the output should contain "Match Requests On: [:method, :uri]"
54
-
55
- Scenario: `:record` defaults to `:once` when it has not been set
56
- Given a file named "default_record_mode.rb" with:
57
- """ruby
58
- require 'vcr'
59
-
60
- VCR.configure do |c|
61
- # not important for this example, but must be set to something
62
- c.hook_into :webmock
63
- c.cassette_library_dir = 'cassettes'
64
- end
65
-
66
- VCR.use_cassette('example') do
67
- puts "Record mode: #{VCR.current_cassette.record_mode.inspect}"
68
- end
69
- """
70
- When I run `ruby default_record_mode.rb`
71
- Then the output should contain "Record mode: :once"
72
-
73
- Scenario: cassettes can set their own options
74
- Given a file named "default_cassette_options.rb" with:
75
- """ruby
76
- require 'vcr_setup.rb'
77
-
78
- VCR.use_cassette('example', :re_record_interval => 10000) do
79
- puts "Re-record Interval: #{VCR.current_cassette.re_record_interval}"
80
- end
81
- """
82
- When I run `ruby default_cassette_options.rb`
83
- Then the output should contain "Re-record Interval: 10000"
84
-
85
- Scenario: cassettes can override default options
86
- Given a file named "default_cassette_options.rb" with:
87
- """ruby
88
- require 'vcr_setup.rb'
89
-
90
- VCR.use_cassette('example', :record => :none, :erb => false) do
91
- puts "Record Mode: #{VCR.current_cassette.record_mode}"
92
- puts "ERB: #{VCR.current_cassette.erb}"
93
- end
94
- """
95
- When I run `ruby default_cassette_options.rb`
96
- Then the output should contain:
97
- """
98
- Record Mode: none
99
- ERB: false
100
- """