vcr 6.3.1 → 6.4.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 +4 -4
- data/lib/vcr/configuration.rb +8 -3
- data/lib/vcr/structs.rb +27 -48
- data/lib/vcr/version.rb +1 -1
- metadata +7 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '029f040c2799268426ac716845881b02d589948a361736e8448eac26b15da750'
|
|
4
|
+
data.tar.gz: 33334bf1404877fbbe62172c2f1f18ca54849c4e5b4ed8fa9e5f5ca0f1defce5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 417c8864eb697e8009d16941ddceb796e4ebb36b8d4163ff6f8ff94be40a188f4d70a27091c1a6d4ef9972cd73baa9aed24aaa12fcc71d2abb7c8c8d50613bbb
|
|
7
|
+
data.tar.gz: 327d05ab66eac55749a5e455cb80e2d953277fc557bb1a47bb0d707b734c82149fb59060eafce34373586755b58a9af9aa6a591cecfa646429344b9e1a98d0dd
|
data/lib/vcr/configuration.rb
CHANGED
|
@@ -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.
|
|
@@ -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 `
|
|
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
|
|
@@ -502,7 +501,13 @@ module VCR
|
|
|
502
501
|
}
|
|
503
502
|
|
|
504
503
|
self.uri_parser = URI
|
|
505
|
-
|
|
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
|
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
|
-
|
|
22
|
-
force_encode_string(
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def try_encode_string(string, encoding_name)
|
|
35
|
-
return string if encoding_name.nil?
|
|
27
|
+
def force_encode_string(string, encoding)
|
|
28
|
+
return string unless encoding
|
|
29
|
+
string.force_encoding(encoding)
|
|
30
|
+
end
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
def try_encode_string(string, encoding_name)
|
|
33
|
+
return string if encoding_name.nil? || string.nil?
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
# Instead, we'll force encode it (essentially just tagging it as binary)
|
|
43
|
-
return string.force_encoding(encoding) if encoding == Encoding::BINARY
|
|
35
|
+
encoding = Encoding.find(encoding_name)
|
|
36
|
+
return string if string.encoding == encoding
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
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.force_encoding(encoding) if encoding == Encoding::BINARY
|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95
|
-
|
|
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
|
|
|
@@ -416,9 +400,7 @@ module VCR
|
|
|
416
400
|
case type
|
|
417
401
|
when 'gzip'
|
|
418
402
|
body_str = ''
|
|
419
|
-
|
|
420
|
-
args << { :encoding => 'ASCII-8BIT' } if ''.respond_to?(:encoding)
|
|
421
|
-
writer = Zlib::GzipWriter.new(*args)
|
|
403
|
+
writer = Zlib::GzipWriter.new(StringIO.new(body_str), encoding: 'ASCII-8BIT')
|
|
422
404
|
writer.write(body)
|
|
423
405
|
writer.close
|
|
424
406
|
body_str
|
|
@@ -457,10 +439,7 @@ module VCR
|
|
|
457
439
|
|
|
458
440
|
case type
|
|
459
441
|
when 'gzip'
|
|
460
|
-
|
|
461
|
-
gzip_reader_options[:encoding] = 'ASCII-8BIT' if ''.respond_to?(:encoding)
|
|
462
|
-
yield Zlib::GzipReader.new(StringIO.new(body),
|
|
463
|
-
**gzip_reader_options).read
|
|
442
|
+
yield Zlib::GzipReader.new(StringIO.new(body), encoding: 'ASCII-8BIT').read
|
|
464
443
|
when 'deflate'
|
|
465
444
|
yield Zlib::Inflate.inflate(body)
|
|
466
445
|
when 'identity', NilClass
|
data/lib/vcr/version.rb
CHANGED
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.
|
|
4
|
+
version: 6.4.0
|
|
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:
|
|
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
|
-
|
|
65
|
+
metadata:
|
|
66
|
+
changelog_uri: https://github.com/vcr/vcr/blob/v6.4.0/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:
|
|
97
|
-
signing_key:
|
|
82
|
+
rubygems_version: 4.0.1
|
|
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.
|