vcr 6.3.1 → 6.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c75512238b9fd8f2774a2508b2ad27698bdf4a6b80fc01abed306602ffa6530
4
- data.tar.gz: 0ca858aeb73f9ff198ef0be4e0cdfd563758a54c75c6dcb17bdfc9d98325b21d
3
+ metadata.gz: 8d9f32f07f523abec1ff78ce1c27771cbc7dd0568c80952075c4f28757b6261f
4
+ data.tar.gz: f4cb9ab001e861be14abee247c834aa5364b4858576bbb4e7dd11ce590f23692
5
5
  SHA512:
6
- metadata.gz: 7d6d31a3c3c26c74602812e6c822605acaa43548af427fd62f1f6d5f9e42390b09cb5d54f78fa593851dcf9db103624309450d933bde7ae5868ac1d2b0c1e8b2
7
- data.tar.gz: a62754daf2fc0c57b950c60874870844692770e911a9ff8f8b7d770576ebc2c64f9043962192526c1d00d9c4bfa4417bc85237f2a07cb67f01eda2efbdc687b0
6
+ metadata.gz: 4069dfa5b9bf2f682fcff97d9c81fbd4364466a75b1126e3360af71668771d4d1fe0bfd6d6c13f5fa7d0335c4c7ad6eacf655a3ed818a7a5d0851d6aff25270d
7
+ data.tar.gz: 992c507dcde216017705d4c9550ba9343a8171fe6cc5f633c4c1faca20f0c4bc177906eed9d3831235bdc051141de6dbe225d9fc9dcec85b36afed695fcabe7d
@@ -23,7 +23,7 @@ module VCR
23
23
 
24
24
  raise Errors::MissingERBVariableError.new(
25
25
  "The ERB in the #{@cassette_name} cassette file references undefined variable #{e.name}. " +
26
- "Pass it to the cassette using :erb => #{ example_hash.inspect }."
26
+ "Pass it to the cassette using erb: #{ example_hash.inspect }."
27
27
  )
28
28
  end
29
29
 
@@ -102,7 +102,7 @@ module VCR
102
102
  end
103
103
 
104
104
  EMPTY_STRING = if String.method_defined?(:force_encoding)
105
- ''.force_encoding("US-ASCII")
105
+ String.new.force_encoding("US-ASCII")
106
106
  else
107
107
  ''
108
108
  end
data/lib/vcr/cassette.rb CHANGED
@@ -64,7 +64,7 @@ module VCR
64
64
  extract_options
65
65
  raise_error_unless_valid_record_mode
66
66
 
67
- log "Initialized with options: #{@options.inspect}"
67
+ log "Initialized with options: #{format_options_for_log(@options)}"
68
68
  end
69
69
 
70
70
  # Ejects the current cassette. The cassette will no longer be used.
@@ -147,10 +147,17 @@ module VCR
147
147
 
148
148
  # @return [Hash] The hash that will be serialized when the cassette is written to disk.
149
149
  def serializable_hash
150
- {
150
+ hash = {
151
151
  "http_interactions" => interactions_to_record.map(&:to_hash),
152
152
  "recorded_with" => "VCR #{VCR.version}"
153
153
  }
154
+ hash["metadata"] = metadata unless metadata.empty?
155
+ hash
156
+ end
157
+
158
+ # @return [Hash] Custom metadata associated with the cassette.
159
+ def metadata
160
+ @metadata ||= recording? ? {} : (deserialized_hash['metadata'] || {})
154
161
  end
155
162
 
156
163
  # @return [Time, nil] The `recorded_at` time of the first HTTP interaction
@@ -214,6 +221,7 @@ module VCR
214
221
  @previously_recorded_interactions ||= if !raw_cassette_bytes.to_s.empty?
215
222
  deserialized_hash['http_interactions'].map { |h| HTTPInteraction.from_hash(h) }.tap do |interactions|
216
223
  invoke_hook(:before_playback, interactions)
224
+ invoke_hook(:recompress_response, interactions)
217
225
 
218
226
  interactions.reject! do |i|
219
227
  i.request.uri.is_a?(String) && VCR.request_ignorer.ignore?(i.request)
@@ -338,6 +346,16 @@ module VCR
338
346
  @log_prefix ||= "[Cassette: '#{name}'] "
339
347
  end
340
348
 
349
+ # Use the legacy `{:key=>val}` format (Ruby 3.4 changed Hash#inspect for symbol keys).
350
+ def format_options_for_log(value)
351
+ case value
352
+ when Hash
353
+ "{#{value.map { |k, v| "#{k.inspect}=>#{format_options_for_log(v)}" }.join(', ')}}"
354
+ else
355
+ value.inspect
356
+ end
357
+ end
358
+
341
359
  def request_summary(request)
342
360
  super(request, match_requests_on)
343
361
  end
@@ -1,6 +1,5 @@
1
1
  require 'vcr/util/hooks'
2
2
  require 'uri'
3
- require 'cgi'
4
3
 
5
4
  module VCR
6
5
  # Stores the VCR configuration.
@@ -40,7 +39,7 @@ module VCR
40
39
  # @return [void]
41
40
  # @example
42
41
  # VCR.configure do |c|
43
- # c.default_cassette_options = { :record => :new_episodes }
42
+ # c.default_cassette_options = { record: :new_episodes }
44
43
  # end
45
44
  # @note {VCR#insert_cassette} for the list of valid options.
46
45
  attr_reader :default_cassette_options
@@ -142,7 +141,7 @@ module VCR
142
141
  # The `#==` method must return true if both objects represent the
143
142
  # same query string.
144
143
  #
145
- # This defaults to `CGI.parse` from the ruby standard library.
144
+ # This defaults to `URI.decode_www_form` from the ruby standard library.
146
145
  #
147
146
  # @overload query_parser
148
147
  # @return [#call] the current query string parser object
@@ -185,7 +184,7 @@ module VCR
185
184
  # end
186
185
  # end
187
186
  #
188
- # VCR.use_cassette("my_cassette", :match_requests_on => [:method, :host, :port]) do
187
+ # VCR.use_cassette("my_cassette", match_requests_on: [:method, :host, :port]) do
189
188
  # # ...
190
189
  # end
191
190
  #
@@ -491,18 +490,24 @@ module VCR
491
490
  @allow_http_connections_when_no_cassette = nil
492
491
  @rspec_metadata_configured = false
493
492
  @default_cassette_options = {
494
- :record => :once,
495
- :record_on_error => true,
496
- :match_requests_on => RequestMatcherRegistry::DEFAULT_MATCHERS,
497
- :allow_unused_http_interactions => true,
498
- :drop_unused_requests => false,
499
- :serialize_with => :yaml,
500
- :persist_with => :file_system,
501
- :persister_options => {}
493
+ record: :once,
494
+ record_on_error: true,
495
+ match_requests_on: RequestMatcherRegistry::DEFAULT_MATCHERS,
496
+ allow_unused_http_interactions: true,
497
+ drop_unused_requests: false,
498
+ serialize_with: :yaml,
499
+ persist_with: :file_system,
500
+ persister_options: {}
502
501
  }
503
502
 
504
503
  self.uri_parser = URI
505
- self.query_parser = CGI.method(:parse)
504
+ # Use URI.decode_www_form instead of CGI.parse for Ruby 3.5+ compatibility
505
+ # Convert the array of pairs format to CGI.parse's hash of arrays format
506
+ self.query_parser = lambda do |query_string|
507
+ result = Hash.new { |h, k| h[k] = [] }
508
+ URI.decode_www_form(query_string.to_s).each { |k, v| result[k] << v }
509
+ result
510
+ end
506
511
  self.debug_logger = nil
507
512
 
508
513
  register_built_in_hooks
@@ -561,8 +566,10 @@ module VCR
561
566
  lambda { |arg| arg.send(object) }
562
567
  end
563
568
 
569
+ define_hook :recompress_response
570
+
564
571
  def register_built_in_hooks
565
- before_playback(:recompress_response) do |interaction|
572
+ recompress_response(tag_filter_from(:recompress_response)) do |interaction|
566
573
  interaction.response.recompress if interaction.response.vcr_decompressed?
567
574
  end
568
575
 
data/lib/vcr/errors.rb CHANGED
@@ -157,8 +157,8 @@ module VCR
157
157
  lines = current_cassettes.inject(lines) do |memo, cassette|
158
158
  memo.concat([
159
159
  " - #{cassette.file}",
160
- " - :record => #{cassette.record_mode.inspect}",
161
- " - :match_requests_on => #{cassette.match_requests_on.inspect}"
160
+ " - record: #{cassette.record_mode.inspect}",
161
+ " - match_requests_on: #{cassette.match_requests_on.inspect}"
162
162
  ])
163
163
  end
164
164
 
@@ -192,27 +192,27 @@ module VCR
192
192
 
193
193
  # List of suggestions for how to configure VCR to handle the request.
194
194
  ALL_SUGGESTIONS = {
195
- :use_new_episodes => [
195
+ use_new_episodes: [
196
196
  ["You can use the :new_episodes record mode to allow VCR to",
197
197
  "record this new request to the existing cassette"],
198
198
  "https://benoittgt.github.io/vcr/?v=%s#/record_modes/new_episodes"
199
199
  ],
200
200
 
201
- :delete_cassette_for_once => [
201
+ delete_cassette_for_once: [
202
202
  ["The current record mode (:once) does not allow new requests to be recorded",
203
203
  "to a previously recorded cassette. You can delete the cassette file and re-run",
204
204
  "your tests to allow the cassette to be recorded with this request"],
205
205
  "https://benoittgt.github.io/vcr/?v=%s#/record_modes/once"
206
206
  ],
207
207
 
208
- :deal_with_none => [
208
+ deal_with_none: [
209
209
  ["The current record mode (:none) does not allow requests to be recorded. You",
210
210
  "can temporarily change the record mode to :once, delete the cassette file ",
211
211
  "and re-run your tests to allow the cassette to be recorded with this request"],
212
212
  "https://benoittgt.github.io/vcr/?v=%s#/record_modes/none"
213
213
  ],
214
214
 
215
- :none_without_file => [
215
+ none_without_file: [
216
216
  ["The current record mode (:none) does not allow requests to be recorded.",
217
217
  "One or more cassette names registered was not found. Use ",
218
218
  ":new_episodes or :once record modes to record a new cassette"],
@@ -220,27 +220,27 @@ module VCR
220
220
  ],
221
221
 
222
222
 
223
- :use_a_cassette => [
223
+ use_a_cassette: [
224
224
  ["If you want VCR to record this request and play it back during future test",
225
225
  "runs, you should wrap your test (or this portion of your test) in a",
226
226
  "`VCR.use_cassette` block"],
227
227
  "https://benoittgt.github.io/vcr/?v=%s#/getting_started"
228
228
  ],
229
229
 
230
- :allow_http_connections_when_no_cassette => [
230
+ allow_http_connections_when_no_cassette: [
231
231
  ["If you only want VCR to handle requests made while a cassette is in use,",
232
232
  "configure `allow_http_connections_when_no_cassette = true`. VCR will",
233
233
  "ignore this request since it is made when there is no cassette"],
234
234
  "https://benoittgt.github.io/vcr/?v=%s#/configuration/allow_http_connections_when_no_cassette"
235
235
  ],
236
236
 
237
- :ignore_request => [
237
+ ignore_request: [
238
238
  ["If you want VCR to ignore this request (and others like it), you can",
239
239
  "set an `ignore_request` callback"],
240
240
  "https://benoittgt.github.io/vcr/?v=%s#/configuration/ignore_request"
241
241
  ],
242
242
 
243
- :allow_playback_repeats => [
243
+ allow_playback_repeats: [
244
244
  ["The cassette contains an HTTP interaction that matches this request,",
245
245
  "but it has already been played back. If you wish to allow a single HTTP",
246
246
  "interaction to be played back multiple times, set the `:allow_playback_repeats`",
@@ -248,7 +248,7 @@ module VCR
248
248
  "https://benoittgt.github.io/vcr/?v=%s#/request_matching/playback_repeats"
249
249
  ],
250
250
 
251
- :match_requests_on => [
251
+ match_requests_on: [
252
252
  ["The cassette contains %s not been",
253
253
  "played back. If your request is non-deterministic, you may need to",
254
254
  "change your :match_requests_on cassette option to be more lenient",
@@ -256,7 +256,7 @@ module VCR
256
256
  "https://benoittgt.github.io/vcr/?v=%s#/request_matching"
257
257
  ],
258
258
 
259
- :try_debug_logger => [
259
+ try_debug_logger: [
260
260
  ["If you're surprised VCR is raising this error",
261
261
  "and want insight about how VCR attempted to handle the request,",
262
262
  "you can use the debug_logger configuration option to log more details"],
@@ -40,13 +40,13 @@ module VCR
40
40
 
41
41
  def on_stubbed_by_vcr_request
42
42
  response = ::Typhoeus::Response.new \
43
- :http_version => stubbed_response.http_version,
44
- :code => stubbed_response.status.code,
45
- :status_message => stubbed_response.status.message,
46
- :headers => stubbed_response_headers,
47
- :body => stubbed_response.body,
48
- :effective_url => stubbed_response.adapter_metadata.fetch('effective_url', request.url),
49
- :mock => true
43
+ http_version: stubbed_response.http_version,
44
+ code: stubbed_response.status.code,
45
+ status_message: stubbed_response.status.message,
46
+ headers: stubbed_response_headers,
47
+ body: stubbed_response.body,
48
+ effective_url: stubbed_response.adapter_metadata.fetch('effective_url', request.url),
49
+ mock: true
50
50
 
51
51
  first_header_line = "HTTP/#{stubbed_response.http_version} #{response.code} #{response.status_message}\r\n"
52
52
  response.instance_variable_set(:@first_header_line, first_header_line)
@@ -122,9 +122,9 @@ module VCR
122
122
 
123
123
  def on_stubbed_by_vcr_request
124
124
  {
125
- :body => stubbed_response.body.dup, # Excon mutates the body, so we must dup it :-(
126
- :status => [stubbed_response.status.code.to_i, stubbed_response.status.message],
127
- :headers => stubbed_response.headers
125
+ body: stubbed_response.body.dup, # Excon mutates the body, so we must dup it :-(
126
+ status: [stubbed_response.status.code.to_i, stubbed_response.status.message],
127
+ headers: stubbed_response.headers
128
128
  }
129
129
  end
130
130
  end
@@ -135,7 +135,7 @@ module VCR
135
135
  global_hook_disabled?(req) ? nil : RequestHandler.new(req).handle
136
136
  end
137
137
 
138
- ::WebMock.after_request(:real_requests_only => true) do |request, response|
138
+ ::WebMock.after_request(real_requests_only: true) do |request, response|
139
139
  unless VCR.library_hooks.disabled?(:webmock)
140
140
  http_interaction = VCR::HTTPInteraction.new \
141
141
  typed_request_for(request), vcr_response_for(response)
@@ -102,9 +102,9 @@ module VCR
102
102
 
103
103
  def on_stubbed_by_vcr_request
104
104
  request_params[:response] = {
105
- :body => stubbed_response.body.dup, # Excon mutates the body, so we must dup it :-(
106
- :headers => normalized_headers(stubbed_response.headers || {}),
107
- :status => stubbed_response.status.code
105
+ body: stubbed_response.body.dup, # Excon mutates the body, so we must dup it :-(
106
+ headers: normalized_headers(stubbed_response.headers || {}),
107
+ status: stubbed_response.status.code
108
108
  }
109
109
  end
110
110
 
@@ -100,7 +100,7 @@ module VCR
100
100
  def on_stubbed_by_vcr_request
101
101
  headers = env[:response_headers] ||= ::Faraday::Utils::Headers.new
102
102
  headers.update stubbed_response.headers if stubbed_response.headers
103
- env.update :status => stubbed_response.status.code, :body => stubbed_response.body
103
+ env.update status: stubbed_response.status.code, body: stubbed_response.body
104
104
 
105
105
  @vcr_response = stubbed_response
106
106
 
@@ -33,7 +33,7 @@ module VCR
33
33
  # app = Rack::Builder.new do
34
34
  # use VCR::Middleware::Rack do |cassette, env|
35
35
  # cassette.name "rack/#{env['SERVER_NAME']}"
36
- # cassette.options :record => :new_episodes
36
+ # cassette.options record: :new_episodes
37
37
  # end
38
38
  #
39
39
  # run MyRackApp
@@ -77,14 +77,14 @@ module VCR
77
77
  # without_timestamp = VCR.request_matchers.uri_without_param(:timestamp)
78
78
  #
79
79
  # # use it directly...
80
- # VCR.use_cassette('example', :match_requests_on => [:method, without_timestamp]) { }
80
+ # VCR.use_cassette('example', match_requests_on: [:method, without_timestamp]) { }
81
81
  #
82
82
  # # ...or register it as a named matcher
83
83
  # VCR.configure do |c|
84
84
  # c.register_request_matcher(:uri_without_timestamp, &without_timestamp)
85
85
  # end
86
86
  #
87
- # VCR.use_cassette('example', :match_requests_on => [:method, :uri_without_timestamp]) { }
87
+ # VCR.use_cassette('example', match_requests_on: [:method, :uri_without_timestamp]) { }
88
88
  #
89
89
  # @param ignores [Array<#to_s>] The names of the query parameters to ignore
90
90
  # @return [#call] the request matcher
data/lib/vcr/structs.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'base64'
2
1
  require 'delegate'
3
2
  require 'time'
4
3
 
@@ -18,46 +17,36 @@ module VCR
18
17
  hash = hash_or_string
19
18
 
20
19
  if hash.has_key?('base64_string')
21
- string = Base64.decode64(hash['base64_string'])
22
- force_encode_string(string, hash['encoding'])
20
+ base64_decoded = hash['base64_string'].unpack1('m')
21
+ force_encode_string(base64_decoded, hash['encoding'])
23
22
  else
24
23
  try_encode_string(hash['string'], hash['encoding'])
25
24
  end
26
25
  end
27
26
 
28
- if "".respond_to?(:encoding)
29
- def force_encode_string(string, encoding)
30
- return string unless encoding
31
- string.force_encoding(encoding)
32
- end
27
+ def force_encode_string(string, encoding)
28
+ return string unless encoding
29
+ string.force_encoding(encoding)
30
+ end
33
31
 
34
- def try_encode_string(string, encoding_name)
35
- return string if encoding_name.nil?
32
+ def try_encode_string(string, encoding_name)
33
+ return string if encoding_name.nil? || string.nil?
36
34
 
37
- encoding = Encoding.find(encoding_name)
38
- return string if string.encoding == encoding
35
+ encoding = Encoding.find(encoding_name)
36
+ return string if string.encoding == encoding
39
37
 
40
- # ASCII-8BIT just means binary, so encoding to it is nonsensical
41
- # and yet "\u00f6".encode("ASCII-8BIT") raises an error.
42
- # Instead, we'll force encode it (essentially just tagging it as binary)
43
- return string.force_encoding(encoding) if encoding == Encoding::BINARY
38
+ # ASCII-8BIT just means binary, so encoding to it is nonsensical
39
+ # and yet "\u00f6".encode("ASCII-8BIT") raises an error.
40
+ # Instead, we'll force encode it (essentially just tagging it as binary)
41
+ return string.dup.force_encoding(encoding) if encoding == Encoding::BINARY
44
42
 
45
- string.encode(encoding)
46
- rescue EncodingError => e
47
- struct_type = name.split('::').last.downcase
48
- warn "VCR: got `#{e.class.name}: #{e.message}` while trying to encode the #{string.encoding.name} " +
49
- "#{struct_type} body to the original body encoding (#{encoding}). Consider using the " +
50
- "`:preserve_exact_body_bytes` option to work around this."
51
- return string
52
- end
53
- else
54
- def force_encode_string(string, encoding)
55
- string
56
- end
57
-
58
- def try_encode_string(string, encoding)
59
- string
60
- end
43
+ string.encode(encoding)
44
+ rescue EncodingError => e
45
+ struct_type = name.split('::').last.downcase
46
+ warn "VCR: got `#{e.class.name}: #{e.message}` while trying to encode the #{string.encoding.name} " +
47
+ "#{struct_type} body to the original body encoding (#{encoding}). Consider using the " +
48
+ "`:preserve_exact_body_bytes` option to work around this."
49
+ return string
61
50
  end
62
51
  end
63
52
 
@@ -85,20 +74,15 @@ module VCR
85
74
  body = String.new(self.body.to_s)
86
75
 
87
76
  if VCR.configuration.preserve_exact_body_bytes_for?(self)
88
- base_body_hash(body).merge('base64_string' => Base64.encode64(body))
77
+ base64_encoded = [body].pack('m')
78
+ base_body_hash(body).merge('base64_string' => base64_encoded)
89
79
  else
90
80
  base_body_hash(body).merge('string' => body)
91
81
  end
92
82
  end
93
83
 
94
- if ''.respond_to?(:encoding)
95
- def base_body_hash(body)
96
- { 'encoding' => body.encoding.name }
97
- end
98
- else
99
- def base_body_hash(body)
100
- { }
101
- end
84
+ def base_body_hash(body)
85
+ { 'encoding' => body.encoding.name }
102
86
  end
103
87
  end
104
88
 
@@ -382,8 +366,10 @@ module VCR
382
366
  end
383
367
 
384
368
  # Checks if the type of encoding is one of "gzip" or "deflate".
369
+ # An empty body is never compressed, whatever the header says: a HEAD
370
+ # response carries the Content-Encoding of the GET it describes.
385
371
  def compressed?
386
- %w[ gzip deflate ].include? content_encoding
372
+ !body.to_s.empty? && %w[ gzip deflate ].include?(content_encoding)
387
373
  end
388
374
 
389
375
  # Checks if VCR decompressed the response body
@@ -397,6 +383,8 @@ module VCR
397
383
  # @raise [VCR::Errors::UnknownContentEncodingError] if the content encoding
398
384
  # is not a known encoding.
399
385
  def decompress
386
+ return self if body.to_s.empty?
387
+
400
388
  self.class.decompress(body, content_encoding) { |new_body|
401
389
  self.body = new_body
402
390
  update_content_length_header
@@ -415,10 +403,8 @@ module VCR
415
403
  new_body = begin
416
404
  case type
417
405
  when 'gzip'
418
- body_str = ''
419
- args = [StringIO.new(body_str)]
420
- args << { :encoding => 'ASCII-8BIT' } if ''.respond_to?(:encoding)
421
- writer = Zlib::GzipWriter.new(*args)
406
+ body_str = String.new
407
+ writer = Zlib::GzipWriter.new(StringIO.new(body_str), encoding: 'ASCII-8BIT')
422
408
  writer.write(body)
423
409
  writer.close
424
410
  body_str
@@ -457,10 +443,7 @@ module VCR
457
443
 
458
444
  case type
459
445
  when 'gzip'
460
- gzip_reader_options = {}
461
- gzip_reader_options[:encoding] = 'ASCII-8BIT' if ''.respond_to?(:encoding)
462
- yield Zlib::GzipReader.new(StringIO.new(body),
463
- **gzip_reader_options).read
446
+ yield Zlib::GzipReader.new(StringIO.new(body), encoding: 'ASCII-8BIT').read
464
447
  when 'deflate'
465
448
  yield Zlib::Inflate.inflate(body)
466
449
  when 'identity', NilClass
@@ -566,11 +549,23 @@ module VCR
566
549
  def filter!(text, replacement_text)
567
550
  text, replacement_text = text.to_s, replacement_text.to_s
568
551
  return self if [text, replacement_text].any? { |t| t.empty? }
552
+ ensure_mutable_strings!(self)
569
553
  filter_object!(self, text, replacement_text)
570
554
  end
571
555
 
572
556
  private
573
557
 
558
+ # Walk the interaction and replace any String values with a dup'd copy
559
+ # so that subsequent in-place mutations (e.g. gsub!) don't trigger
560
+ # "literal string will be frozen" warnings on Ruby 3.4+.
561
+ def ensure_mutable_strings!(object)
562
+ if object.respond_to?(:each_pair) && object.respond_to?(:[]=)
563
+ object.each_pair { |name, v| v.is_a?(String) ? object[name] = v.dup : ensure_mutable_strings!(v) }
564
+ elsif object.is_a?(Array)
565
+ object.each_with_index { |o, i| o.is_a?(String) ? object[i] = o.dup : ensure_mutable_strings!(o) }
566
+ end
567
+ end
568
+
574
569
  def filter_object!(object, text, replacement_text)
575
570
  if object.respond_to?(:gsub)
576
571
  object.gsub!(text, replacement_text) if object.include?(text)
@@ -25,7 +25,7 @@ module VCR
25
25
  #
26
26
  # @param tag_names [Array<String,Hash>] the cucumber scenario tags. If
27
27
  # the last argument is a hash it is treated as cassette options.
28
- # - `:use_scenario_name => true` to automatically name the
28
+ # - `use_scenario_name: true` to automatically name the
29
29
  # cassette according to the scenario name.
30
30
  def tags(*tag_names)
31
31
  original_options = tag_names.last.is_a?(::Hash) ? tag_names.pop : {}
@@ -71,7 +71,7 @@ module VCR
71
71
  end
72
72
 
73
73
  @main_object.After(tag_name) do |scenario|
74
- VCR.eject_cassette(:skip_no_unused_interactions_assertion => scenario.failed?)
74
+ VCR.eject_cassette(skip_no_unused_interactions_assertion: scenario.failed?)
75
75
  end
76
76
 
77
77
  self.class.add_tag(tag_name)
@@ -30,7 +30,7 @@ module VCR
30
30
  def configure!
31
31
  ::RSpec.configure do |config|
32
32
 
33
- when_tagged_with_vcr = { :vcr => lambda { |v| !!v } }
33
+ when_tagged_with_vcr = { vcr: lambda { |v| !!v } }
34
34
 
35
35
  config.before(:each, when_tagged_with_vcr) do |ex|
36
36
  example = ex.respond_to?(:metadata) ? ex : ex.example
@@ -54,7 +54,7 @@ module VCR
54
54
 
55
55
  config.after(:each, when_tagged_with_vcr) do |ex|
56
56
  example = ex.respond_to?(:metadata) ? ex : ex.example
57
- VCR.eject_cassette(:skip_no_unused_interactions_assertion => !!example.exception)
57
+ VCR.eject_cassette(skip_no_unused_interactions_assertion: !!example.exception)
58
58
  end
59
59
  end
60
60
  end
data/lib/vcr/version.rb CHANGED
@@ -10,7 +10,7 @@ module VCR
10
10
  # * `parts` [Array<Integer>] List of the version parts.
11
11
  def version
12
12
  @version ||= begin
13
- string = +'6.3.1'
13
+ string = +'6.4.1'
14
14
 
15
15
  def string.parts
16
16
  split('.').map { |p| p.to_i }
data/lib/vcr.rb CHANGED
@@ -56,7 +56,7 @@ module VCR
56
56
  # `:record` option.
57
57
  #
58
58
  # @example
59
- # VCR.insert_cassette('twitter', :record => :new_episodes)
59
+ # VCR.insert_cassette('twitter', record: :new_episodes)
60
60
  #
61
61
  # # ...later, after making an HTTP request:
62
62
  #
@@ -140,7 +140,7 @@ module VCR
140
140
  cassette
141
141
  elsif !ignore_cassettes?
142
142
  message = "VCR is turned off. You must turn it on before you can insert a cassette. " +
143
- "Or you can use the `:ignore_cassettes => true` option to completely ignore cassette insertions."
143
+ "Or you can use the `ignore_cassettes: true` option to completely ignore cassette insertions."
144
144
  raise TurnedOffError.new(message)
145
145
  end
146
146
  end
@@ -152,7 +152,7 @@ module VCR
152
152
  # @param options [Hash] Eject options.
153
153
  # @option options :skip_no_unused_interactions_assertion [Boolean]
154
154
  # If `true` is given, this will skip the "no unused HTTP interactions"
155
- # assertion enabled by the `:allow_unused_http_interactions => false`
155
+ # assertion enabled by the `allow_unused_http_interactions: false`
156
156
  # cassette option. This is intended for use when your test has had
157
157
  # an error, but your test framework has already handled it.
158
158
  # @return [VCR::Cassette, nil] the ejected cassette if there was one
@@ -168,7 +168,7 @@ module VCR
168
168
  # block, and ejects the cassette.
169
169
  #
170
170
  # @example
171
- # VCR.use_cassette('twitter', :record => :new_episodes) do
171
+ # VCR.use_cassette('twitter', record: :new_episodes) do
172
172
  # # make an HTTP request
173
173
  # end
174
174
  #
@@ -246,7 +246,7 @@ module VCR
246
246
  # @example
247
247
  # VCR.cucumber_tags do |t|
248
248
  # t.tags "tag1", "tag2"
249
- # t.tag "@some_other_tag", :record => :new_episodes
249
+ # t.tag "@some_other_tag", record: :new_episodes
250
250
  # end
251
251
  #
252
252
  # @yield the cucumber tags configuration block
@@ -434,10 +434,10 @@ private
434
434
 
435
435
  def dup_context(context)
436
436
  {
437
- :turned_off => context[:turned_off],
438
- :ignore_cassettes => context[:ignore_cassettes],
439
- :cassettes => [],
440
- :linked_context => context
437
+ turned_off: context[:turned_off],
438
+ ignore_cassettes: context[:ignore_cassettes],
439
+ cassettes: [],
440
+ linked_context: context
441
441
  }
442
442
  end
443
443
 
@@ -462,10 +462,10 @@ private
462
462
  initialize_fibers
463
463
  @context = {
464
464
  MainThread => {
465
- :turned_off => false,
466
- :ignore_cassettes => false,
467
- :cassettes => [],
468
- :linked_context => nil
465
+ turned_off: false,
466
+ ignore_cassettes: false,
467
+ cassettes: [],
468
+ linked_context: nil
469
469
  }
470
470
  }
471
471
  @configuration = Configuration.new
metadata CHANGED
@@ -1,31 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.1
4
+ version: 6.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
8
  - Kurtis Rainbolt-Greene
9
9
  - Olle Jonsson
10
- autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2024-08-20 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: base64
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- version: '0'
12
+ date: 1980-01-02 00:00:00.000000000 Z
13
+ dependencies: []
29
14
  description: Record your test suite's HTTP interactions and replay them during future
30
15
  test runs for fast, deterministic, accurate tests.
31
16
  email:
@@ -77,8 +62,9 @@ homepage: https://benoittgt.github.io/vcr
77
62
  licenses:
78
63
  - Hippocratic-2.1
79
64
  - MIT
80
- metadata: {}
81
- post_install_message:
65
+ metadata:
66
+ changelog_uri: https://github.com/vcr/vcr/blob/v6.4.1/CHANGELOG.md
67
+ funding_uri: https://opencollective.com/vcr
82
68
  rdoc_options: []
83
69
  require_paths:
84
70
  - lib
@@ -93,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
79
  - !ruby/object:Gem::Version
94
80
  version: '0'
95
81
  requirements: []
96
- rubygems_version: 3.5.16
97
- signing_key:
82
+ rubygems_version: 4.0.14
98
83
  specification_version: 4
99
84
  summary: Record your test suite's HTTP interactions and replay them during future
100
85
  test runs for fast, deterministic, accurate tests.