vcr 5.1.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07fd7ce84552274d7b4da982cb81c3952f41745280274b236a8f4b2d22f99c14
4
- data.tar.gz: 52291714128b6cf2ae583098b0e8c25acb1335826bfbbd6f4db778bf11996533
3
+ metadata.gz: 79ff7c5f67afb190b63450e117a7dbda6709340fbab8c17680c36b2bb5a8a6f6
4
+ data.tar.gz: a6a17620c6c63d9a596a39e2700f3f1becddb26bfa63f862e42ef0dfabb783d9
5
5
  SHA512:
6
- metadata.gz: fdcf18897a729f367411a486747e318c870e92c8eb5c234ed1948123501938ccd7966b129ef99658cca62ec0d6762b2fc339c1064527c6de731eed1bfdf53c72
7
- data.tar.gz: 945c7b6cbae5a31ad56d142488dedb69d2554ea2367a157e9693b7771be9fec9e12b74236c3e853b9ab05ffba416bc489055264048b4896efa9030767394a7bb
6
+ metadata.gz: 9f43f626bae24850a8b5f912203dba5ee7e38ef39ecb3d325382ca2cbfb24ff789c3e630edd628588fdd59b0a8b10919bedd820675a039b5d619f1c779dc186b
7
+ data.tar.gz: ffc8534bbab227c6f8f4636306644c1c28d1ac8c2d29d47551d1b84c04cd5c37979acfb44803b18c54ee558e961d92826a38e6a75b93d8002af6adde5f2e7d05
data/lib/vcr.rb CHANGED
@@ -107,6 +107,12 @@ module VCR
107
107
  # @option options :persist_with [Symbol] Which cassette persister to
108
108
  # use. Defaults to :file_system. You can also register and use a
109
109
  # custom persister.
110
+ # @option options :persister_options [Hash] Pass options to the
111
+ # persister specified in `persist_with`. Currently available options for the file_system persister:
112
+ # - `:downcase_cassette_names`: when `true`, names of cassettes will be
113
+ # normalized in lowercase before reading and writing, which can avoid
114
+ # confusion when using both case-sensitive and case-insensitive file
115
+ # systems.
110
116
  # @option options :preserve_exact_body_bytes [Boolean] Whether or not
111
117
  # to base64 encode the bytes of the requests and responses for this cassette
112
118
  # when serializing it. See also `VCR::Configuration#preserve_exact_body_bytes`.
@@ -197,13 +203,13 @@ module VCR
197
203
  # Inserts multiple cassettes the given names
198
204
  #
199
205
  # @example
200
- # cassettes = [
201
- # { name: 'github' },
202
- # { name: 'apple', options: { erb: true } }
203
- # ]
204
- # VCR.use_cassettes() do
205
- # # make multiple HTTP requests
206
- # end
206
+ # cassettes = [
207
+ # { name: 'github' },
208
+ # { name: 'apple', options: { erb: true } }
209
+ # ]
210
+ # VCR.use_cassettes(cassettes) do
211
+ # # make multiple HTTP requests
212
+ # end
207
213
  def use_cassettes(cassettes, &block)
208
214
  cassette = cassettes.pop
209
215
  use_cassette(cassette[:name], cassette[:options] || {}) do
@@ -176,7 +176,7 @@ module VCR
176
176
  :record, :record_on_error, :erb, :match_requests_on, :re_record_interval, :tag, :tags,
177
177
  :update_content_length_header, :allow_playback_repeats, :allow_unused_http_interactions,
178
178
  :exclusive, :serialize_with, :preserve_exact_body_bytes, :decode_compressed_response,
179
- :recompress_response, :persist_with, :clean_outdated_http_interactions
179
+ :recompress_response, :persist_with, :persister_options, :clean_outdated_http_interactions
180
180
  ]
181
181
 
182
182
  if invalid_options.size > 0
@@ -55,7 +55,15 @@ module VCR
55
55
  file_extension = '.' + parts.pop
56
56
  end
57
57
 
58
- parts.join('.').gsub(/[^[:word:]\-\/]+/, '_') + file_extension.to_s
58
+ file_name = parts.join('.').gsub(/[^[:word:]\-\/]+/, '_') + file_extension.to_s
59
+ file_name.downcase! if downcase_cassette_names?
60
+ file_name
61
+ end
62
+
63
+ def downcase_cassette_names?
64
+ !!VCR.configuration
65
+ .default_cassette_options
66
+ .dig(:persister_options, :downcase_cassette_names)
59
67
  end
60
68
  end
61
69
  end
@@ -1,4 +1,4 @@
1
- require 'multi_json'
1
+ require 'json'
2
2
 
3
3
  module VCR
4
4
  class Cassette
@@ -13,8 +13,8 @@ module VCR
13
13
  extend EncodingErrorHandling
14
14
 
15
15
  # @private
16
- ENCODING_ERRORS = [MultiJson::DecodeError, ArgumentError]
17
- ENCODING_ERRORS << EncodingError if defined?(EncodingError)
16
+ ENCODING_ERRORS = [ArgumentError]
17
+ ENCODING_ERRORS << ::JSON::GeneratorError
18
18
 
19
19
  # The file extension to use for this serializer.
20
20
  #
@@ -23,23 +23,23 @@ module VCR
23
23
  "json"
24
24
  end
25
25
 
26
- # Serializes the given hash using `MultiJson`.
26
+ # Serializes the given hash using `JSON`.
27
27
  #
28
28
  # @param [Hash] hash the object to serialize
29
29
  # @return [String] the JSON string
30
30
  def serialize(hash)
31
31
  handle_encoding_errors do
32
- MultiJson.encode(hash)
32
+ ::JSON.generate(hash)
33
33
  end
34
34
  end
35
35
 
36
- # Deserializes the given string using `MultiJson`.
36
+ # Deserializes the given string using `JSON`.
37
37
  #
38
38
  # @param [String] string the JSON string
39
39
  # @return [Hash] the deserialized object
40
40
  def deserialize(string)
41
41
  handle_encoding_errors do
42
- MultiJson.decode(string)
42
+ ::JSON.parse(string)
43
43
  end
44
44
  end
45
45
  end
@@ -496,7 +496,8 @@ module VCR
496
496
  :match_requests_on => RequestMatcherRegistry::DEFAULT_MATCHERS,
497
497
  :allow_unused_http_interactions => true,
498
498
  :serialize_with => :yaml,
499
- :persist_with => :file_system
499
+ :persist_with => :file_system,
500
+ :persister_options => {}
500
501
  }
501
502
 
502
503
  self.uri_parser = URI
@@ -9,8 +9,8 @@ module VCR
9
9
  include Enumerable
10
10
 
11
11
  # Creates a new list of context-owned cassettes and linked cassettes
12
- # @param [Array] context-owned cassettes
13
- # @param [Array] context-unowned (linked) cassettes
12
+ # @param cassettes [Array] context-owned cassettes
13
+ # @param linked_cassettes [Array] context-unowned (linked) cassettes
14
14
  def initialize(cassettes, linked_cassettes)
15
15
  @cassettes = cassettes
16
16
  @linked_cassettes = linked_cassettes
@@ -52,8 +52,8 @@ module VCR
52
52
  end
53
53
 
54
54
  # Create a new CassetteList
55
- # @param [Array] context-owned cassettes
56
- # @param [Array] context-unowned (linked) cassettes
55
+ # @param cassettes [Array] context-owned cassettes
56
+ # @param linked_cassettes [Array] context-unowned (linked) cassettes
57
57
  def self.list(cassettes, linked_cassettes)
58
58
  CassetteList.new(cassettes, linked_cassettes)
59
59
  end
@@ -31,6 +31,11 @@ module VCR
31
31
  RequestHandler.new(@app, env).handle
32
32
  end
33
33
 
34
+ # Close any persistent connections.
35
+ def close
36
+ @app.close if @app.respond_to?(:close)
37
+ end
38
+
34
39
  # @private
35
40
  class RequestHandler < ::VCR::RequestHandler
36
41
  attr_reader :app, :env
@@ -346,9 +346,9 @@ module VCR
346
346
  {
347
347
  'status' => status.to_hash,
348
348
  'headers' => headers,
349
- 'body' => serializable_body,
350
- 'http_version' => http_version
349
+ 'body' => serializable_body
351
350
  }.tap do |hash|
351
+ hash['http_version'] = http_version if http_version
352
352
  hash['adapter_metadata'] = adapter_metadata unless adapter_metadata.empty?
353
353
  end
354
354
  end
@@ -454,9 +454,10 @@ module VCR
454
454
 
455
455
  case type
456
456
  when 'gzip'
457
- args = [StringIO.new(body)]
458
- args << { :encoding => 'ASCII-8BIT' } if ''.respond_to?(:encoding)
459
- yield Zlib::GzipReader.new(*args).read
457
+ gzip_reader_options = {}
458
+ gzip_reader_options[:encoding] = 'ASCII-8BIT' if ''.respond_to?(:encoding)
459
+ yield Zlib::GzipReader.new(StringIO.new(body),
460
+ **gzip_reader_options).read
460
461
  when 'deflate'
461
462
  yield Zlib::Inflate.inflate(body)
462
463
  when 'identity', NilClass
@@ -23,10 +23,10 @@ module VCR
23
23
  # Adds `Before` and `After` cucumber hooks for the named tags that
24
24
  # will cause a VCR cassette to be used for scenarios with matching tags.
25
25
  #
26
- # @param [Array<String>] tag_names the cucumber scenario tags
27
- # @param [(optional) Hash] options the cassette options. Specify
28
- # `:use_scenario_name => true` to automatically name the
29
- # cassette according to the scenario name.
26
+ # @param tag_names [Array<String,Hash>] the cucumber scenario tags. If
27
+ # the last argument is a hash it is treated as cassette options.
28
+ # - `:use_scenario_name => true` to automatically name the
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 : {}
32
32
  tag_names.each do |tag_name|
@@ -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 = '5.1.0'
13
+ string = '6.0.0'
14
14
 
15
15
  def string.parts
16
16
  split('.').map { |p| p.to_i }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-02-05 00:00:00.000000000 Z
13
+ date: 2020-05-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -178,42 +178,48 @@ dependencies:
178
178
  requirements:
179
179
  - - "~>"
180
180
  - !ruby/object:Gem::Version
181
- version: 2.0.2
181
+ version: '3.1'
182
182
  type: :development
183
183
  prerelease: false
184
184
  version_requirements: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - "~>"
187
187
  - !ruby/object:Gem::Version
188
- version: 2.0.2
188
+ version: '3.1'
189
189
  - !ruby/object:Gem::Dependency
190
190
  name: aruba
191
191
  requirement: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
- version: 0.14.12
195
+ version: 0.14.14
196
196
  type: :development
197
197
  prerelease: false
198
198
  version_requirements: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - "~>"
201
201
  - !ruby/object:Gem::Version
202
- version: 0.14.12
202
+ version: 0.14.14
203
203
  - !ruby/object:Gem::Dependency
204
204
  name: faraday
205
205
  requirement: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - "~>"
207
+ - - ">="
208
208
  - !ruby/object:Gem::Version
209
209
  version: 0.11.0
210
+ - - "<"
211
+ - !ruby/object:Gem::Version
212
+ version: 2.0.0
210
213
  type: :development
211
214
  prerelease: false
212
215
  version_requirements: !ruby/object:Gem::Requirement
213
216
  requirements:
214
- - - "~>"
217
+ - - ">="
215
218
  - !ruby/object:Gem::Version
216
219
  version: 0.11.0
220
+ - - "<"
221
+ - !ruby/object:Gem::Version
222
+ version: 2.0.0
217
223
  - !ruby/object:Gem::Dependency
218
224
  name: httpclient
219
225
  requirement: !ruby/object:Gem::Requirement
@@ -232,14 +238,14 @@ dependencies:
232
238
  name: excon
233
239
  requirement: !ruby/object:Gem::Requirement
234
240
  requirements:
235
- - - '='
241
+ - - ">="
236
242
  - !ruby/object:Gem::Version
237
243
  version: 0.62.0
238
244
  type: :development
239
245
  prerelease: false
240
246
  version_requirements: !ruby/object:Gem::Requirement
241
247
  requirements:
242
- - - '='
248
+ - - ">="
243
249
  - !ruby/object:Gem::Version
244
250
  version: 0.62.0
245
251
  - !ruby/object:Gem::Dependency
@@ -256,20 +262,6 @@ dependencies:
256
262
  - - ">="
257
263
  - !ruby/object:Gem::Version
258
264
  version: '0'
259
- - !ruby/object:Gem::Dependency
260
- name: multi_json
261
- requirement: !ruby/object:Gem::Requirement
262
- requirements:
263
- - - ">="
264
- - !ruby/object:Gem::Version
265
- version: '0'
266
- type: :development
267
- prerelease: false
268
- version_requirements: !ruby/object:Gem::Requirement
269
- requirements:
270
- - - ">="
271
- - !ruby/object:Gem::Version
272
- version: '0'
273
265
  - !ruby/object:Gem::Dependency
274
266
  name: json
275
267
  requirement: !ruby/object:Gem::Requirement
@@ -376,7 +368,8 @@ files:
376
368
  - lib/vcr/version.rb
377
369
  homepage: https://relishapp.com/vcr/vcr/docs
378
370
  licenses:
379
- - MIT-Hippocratic-1.2
371
+ - Hippocratic-2.1
372
+ - MIT
380
373
  metadata: {}
381
374
  post_install_message:
382
375
  rdoc_options: []
@@ -386,14 +379,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
386
379
  requirements:
387
380
  - - ">="
388
381
  - !ruby/object:Gem::Version
389
- version: 1.9.3
382
+ version: '2.3'
390
383
  required_rubygems_version: !ruby/object:Gem::Requirement
391
384
  requirements:
392
385
  - - ">="
393
386
  - !ruby/object:Gem::Version
394
387
  version: '0'
395
388
  requirements: []
396
- rubygems_version: 3.0.3
389
+ rubygems_version: 3.1.3
397
390
  signing_key:
398
391
  specification_version: 4
399
392
  summary: Record your test suite's HTTP interactions and replay them during future