webmock 3.17.0 → 3.17.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: e83aa4c98567eb2c64f39136600540212c108d9d5596119c81d26457757f5233
4
- data.tar.gz: 78547f4192e94786194a63d4a7c93e144b1a5781c95619e869984d0438dad69d
3
+ metadata.gz: e4cbe1f0f2f191bea7fda094073e265aeff44e1669d1222da5cb724e5124eb55
4
+ data.tar.gz: e631266b6f082b93800e815a9dc0aa071a60a89c1f803bf3eee739e6b97820a2
5
5
  SHA512:
6
- metadata.gz: 6461f17c27d962adc571dc23a9f6f232e4855c71384f7dcb6d8f6132497f46c46c7e196d75d75e920605f5fdc8a70962ac4ea61cd2109340ebb0b6a7cd6a5782
7
- data.tar.gz: '084c4a3a1225eb9b1bd159a831eb9a8dd488493b0253c28773514c6966e0ae89c9f778f14f68ff67d57d7382b6582790f226ae1708c096e28661d4936aacf5e1'
6
+ metadata.gz: 4911f51bd82520812df827796996ab8cf9975f1bee625a158f4644f8c121bbf34172266cd3097ef0609750d51d0c987ea7a645df077f936924f2ea0915f1c0a1
7
+ data.tar.gz: bc053c6d94f668d75c1e97629dd9ba38f018ffb2355f5cd97e1f5e54015f6adf02c6f9cac2abf6b5c13d7d4fcd69d1bae77b45cffa2b2b8488fa4d0a1c53e1b3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ # 3.17.1
4
+
5
+ * Fixed Syntax Error
6
+
7
+ Thanks to [Mark Spangler](https://github.com/mspangler)
8
+
3
9
  # 3.17.0
4
10
 
5
11
  * Minimum required Ruby version is 2.3
data/README.md CHANGED
@@ -1169,6 +1169,7 @@ People who submitted patches and new features or suggested improvements. Many th
1169
1169
  * Go Sueyoshi
1170
1170
  * Cedric Sohrauer
1171
1171
  * Akira Matsuda
1172
+ * Mark Spangler
1172
1173
 
1173
1174
  For a full list of contributors you can visit the
1174
1175
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -165,7 +165,7 @@ module WebMock
165
165
  response.extend Net::WebMockHTTPResponse
166
166
 
167
167
  if webmock_response.should_timeout
168
- raise timeout_exception, "execution expired"
168
+ raise Net::OpenTimeout, "execution expired"
169
169
  end
170
170
 
171
171
  webmock_response.raise_error_if_any
@@ -175,16 +175,6 @@ module WebMock
175
175
  response
176
176
  end
177
177
 
178
- def timeout_exception
179
- if defined?(Net::OpenTimeout)
180
- # Ruby 2.x
181
- Net::OpenTimeout
182
- else
183
- # Fallback, if things change
184
- Timeout::Error
185
- end
186
- end
187
-
188
178
  def build_webmock_response(net_http_response)
189
179
  webmock_response = WebMock::Response.new
190
180
  webmock_response.status = [
@@ -328,7 +318,6 @@ module WebMock
328
318
  method = request.method.downcase.to_sym
329
319
 
330
320
  headers = Hash[*request.to_hash.map {|k,v| [k, v]}.inject([]) {|r,x| r + x}]
331
- validate_headers(headers)
332
321
 
333
322
  if request.body_stream
334
323
  body = request.body_stream.read
@@ -353,25 +342,6 @@ module WebMock
353
342
  "#{protocol}://#{hostname}:#{net_http.port}#{path}"
354
343
  end
355
344
 
356
- def self.validate_headers(headers)
357
- # For Ruby versions < 2.3.0, if you make a request with headers that are symbols
358
- # Net::HTTP raises a NoMethodError
359
- #
360
- # WebMock normalizes headers when creating a RequestSignature,
361
- # and will update all headers from symbols to strings.
362
- #
363
- # This could create a false positive in a test suite with WebMock.
364
- #
365
- # So before this point, WebMock raises an ArgumentError if any of the headers are symbols
366
- # instead of the cryptic NoMethodError "undefined method `split' ...` from Net::HTTP
367
- if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.3.0')
368
- header_as_symbol = headers.keys.find {|header| header.is_a? Symbol}
369
- if header_as_symbol
370
- raise ArgumentError.new("Net:HTTP does not accept headers as symbols")
371
- end
372
- end
373
- end
374
-
375
345
  def self.check_right_http_connection
376
346
  @was_right_http_connection_loaded = defined?(RightHttpConnection)
377
347
  end
@@ -359,7 +359,7 @@ module WebMock
359
359
 
360
360
  query_parameters.each_with_index do |actual, index|
361
361
  expected = pattern[index]
362
- reutrn false unless matching_values(actual, expected, content_type)
362
+ return false unless matching_values(actual, expected, content_type)
363
363
  end
364
364
 
365
365
  true
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.17.0' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.17.1' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -115,33 +115,16 @@ describe "Net:HTTP" do
115
115
  expect(Net::HTTP.start("www.example.com") { |http| http.request(req)}.body).to eq("abc")
116
116
  end
117
117
 
118
- it "raises an ArgumentError if passed headers as symbols if RUBY_VERSION < 2.3.0" do
118
+ it "raises an ArgumentError if passed headers as symbols" do
119
119
  uri = URI.parse("http://google.com/")
120
120
  http = Net::HTTP.new(uri.host, uri.port)
121
121
  request = Net::HTTP::Get.new(uri.request_uri)
122
+ request[:InvalidHeaderSinceItsASymbol] = "this will not be valid"
122
123
 
123
- # Net::HTTP calls downcase on header keys assigned with []=
124
- # In Ruby 1.8.7 symbols do not respond to downcase
125
- #
126
- # Meaning you can not assign header keys as symbols in ruby 1.8.7 using []=
127
- if :symbol.respond_to?(:downcase)
128
- request[:InvalidHeaderSinceItsASymbol] = "this will not be valid"
129
- else
130
- request.instance_eval do
131
- @header = request.to_hash.merge({InvalidHeaderSinceItsASymbol: "this will not be valid"})
132
- end
133
- end
134
-
135
- if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.3.0')
136
- expect do
137
- http.request(request)
138
- end.to raise_error ArgumentError, "Net:HTTP does not accept headers as symbols"
139
- else
140
- stub_http_request(:get, "google.com").with(headers: { InvalidHeaderSinceItsASymbol: "this will not be valid" })
141
- expect do
142
- http.request(request)
143
- end.not_to raise_error
144
- end
124
+ stub_http_request(:get, "google.com").with(headers: { InvalidHeaderSinceItsASymbol: "this will not be valid" })
125
+ expect do
126
+ http.request(request)
127
+ end.not_to raise_error
145
128
  end
146
129
 
147
130
  it "should handle multiple values for the same response header" do
@@ -93,31 +93,29 @@ unless RUBY_PLATFORM =~ /java/
93
93
  @sess.copy("/abc", "/def")
94
94
  end
95
95
 
96
- if /^1\.9/ === RUBY_VERSION
97
- describe "handling encoding same way as patron" do
98
- around(:each) do |example|
99
- @encoding = Encoding.default_internal
100
- Encoding.default_internal = "UTF-8"
101
- example.run
102
- Encoding.default_internal = @encoding
103
- end
96
+ describe "handling encoding same way as patron" do
97
+ around(:each) do |example|
98
+ @encoding = Encoding.default_internal
99
+ Encoding.default_internal = "UTF-8"
100
+ example.run
101
+ Encoding.default_internal = @encoding
102
+ end
104
103
 
105
- it "should not encode body with default encoding" do
106
- stub_request(:get, "www.example.com").
107
- to_return(body: "Øl")
104
+ it "should not encode body with default encoding" do
105
+ stub_request(:get, "www.example.com").
106
+ to_return(body: "Øl")
108
107
 
109
- expect(@sess.get("").body.encoding).to eq(Encoding::ASCII_8BIT)
110
- expect(@sess.get("").inspectable_body.encoding).to eq(Encoding::UTF_8)
111
- end
108
+ expect(@sess.get("").body.encoding).to eq(Encoding::ASCII_8BIT)
109
+ expect(@sess.get("").inspectable_body.encoding).to eq(Encoding::UTF_8)
110
+ end
112
111
 
113
- it "should not encode body to default internal" do
114
- stub_request(:get, "www.example.com").
115
- to_return(headers: {'Content-Type' => 'text/html; charset=iso-8859-1'},
116
- body: "Øl".encode("iso-8859-1"))
112
+ it "should not encode body to default internal" do
113
+ stub_request(:get, "www.example.com").
114
+ to_return(headers: {'Content-Type' => 'text/html; charset=iso-8859-1'},
115
+ body: "Øl".encode("iso-8859-1"))
117
116
 
118
- expect(@sess.get("").body.encoding).to eq(Encoding::ASCII_8BIT)
119
- expect(@sess.get("").decoded_body.encoding).to eq(Encoding.default_internal)
120
- end
117
+ expect(@sess.get("").body.encoding).to eq(Encoding::ASCII_8BIT)
118
+ expect(@sess.get("").decoded_body.encoding).to eq(Encoding.default_internal)
121
119
  end
122
120
  end
123
121
  end
@@ -553,6 +553,12 @@ describe WebMock::RequestPattern do
553
553
  headers: {content_type: content_type}, body: "[{\"a\":1}]"))
554
554
  end
555
555
 
556
+ it "should not match if the request body has a different top level array" do
557
+ expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: ["a", "b"])).
558
+ not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
559
+ headers: {content_type: content_type}, body: "[\"a\", \"c\"]"))
560
+ end
561
+
556
562
  it "should not match when body is not json" do
557
563
  expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
558
564
  not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.0
4
+ version: 3.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Blimke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-05 00:00:00.000000000 Z
11
+ date: 2022-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -421,9 +421,9 @@ licenses:
421
421
  - MIT
422
422
  metadata:
423
423
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
424
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.17.0/CHANGELOG.md
425
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.17.0
426
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.17.0
424
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.17.1/CHANGELOG.md
425
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.17.1
426
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.17.1
427
427
  wiki_uri: https://github.com/bblimke/webmock/wiki
428
428
  post_install_message:
429
429
  rdoc_options: []