webmock 3.8.0 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7f69433e4cc2a3e16c2ba55df62db7f99585200c9bc9bc1d1e9f53df9fc8bb6
4
- data.tar.gz: ffa4936d1432c8256bcd244db949cd75342170d60c9920707846ae6d12540434
3
+ metadata.gz: f4eb1f45308b980dfaa6f5e292efad872723d4f4d5d51a2edc07fac71f58ff79
4
+ data.tar.gz: b26aea6c4f2823a534274984ddf7a1d77bf69b0f9eb41e62dea9341c13efa028
5
5
  SHA512:
6
- metadata.gz: 272c6a7bab37739d29fe8412264227325c4ceda06d17a6df13ba6ed317bda6770865063ef99b215c7880029f4a4dca1114e88fb5c0c017efeddee3a67f68cdf9
7
- data.tar.gz: b86032f68e0e058d99c2ab61b1d360756d9bf4611cf383588feaad866a1d33964b4150a7819f5c1b0c64651539aed99499de7f8e1efbac476f99769f76abcfd4
6
+ metadata.gz: d914ab7d87674019a2f2ffe195a296ff488067b2971caf588f221ff6810fdbc7b646f529c680d7b0aefd09eb98a6db7b66fa1c8767f0fe6ee244df32e5ac583a
7
+ data.tar.gz: af18127a0082d5b74b400af4406909393de802ffc775ed5ecae25305ea0d06dbd571ed92d042d064c0aefad4e07b5ff32a660037fc63467143a4e0a71be3309b
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.8.1
4
+
5
+ * Added support for mocking non-ASCII bodies when making requests with HTTP.rb
6
+
7
+ Thanks to [Patrik Ragnarsson](https://github.com/dentarg)
8
+
3
9
  ## 3.8.0
4
10
 
5
11
  * Fixed options handling when initialising Async::HTTP::Client
data/README.md CHANGED
@@ -1118,6 +1118,7 @@ People who submitted patches and new features or suggested improvements. Many th
1118
1118
  * Ryan Davis
1119
1119
  * Brandur
1120
1120
  * Samuel Williams
1121
+ * Patrik Ragnarsson
1121
1122
 
1122
1123
  For a full list of contributors you can visit the
1123
1124
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -14,7 +14,7 @@ module HTTP
14
14
  def from_webmock(webmock_response, request_signature = nil)
15
15
  status = Status.new(webmock_response.status.first)
16
16
  headers = webmock_response.headers || {}
17
- body = Body.new Streamer.new webmock_response.body
17
+ body = Body.new(Streamer.new(webmock_response.body), encoding: webmock_response.body.encoding)
18
18
  uri = normalize_uri(request_signature && request_signature.uri)
19
19
 
20
20
  return new(status, "1.1", headers, body, uri) if HTTP::VERSION < "1.0.0"
@@ -279,19 +279,22 @@ module Net #:nodoc: all
279
279
  end
280
280
 
281
281
  if RUBY_VERSION >= '2.6.0'
282
+ # https://github.com/ruby/ruby/blob/7d02441f0d6e5c9d0a73a024519eba4f69e36dce/lib/net/protocol.rb#L208
283
+ # Modified version of method from ruby, so that nil is always passed into orig_read_nonblock to avoid timeout
282
284
  def rbuf_fill
283
- current_thread_id = Thread.current.object_id
284
-
285
- trace = TracePoint.trace(:line) do |tp|
286
- next unless Thread.current.object_id == current_thread_id
287
- if tp.binding.local_variable_defined?(:tmp)
288
- tp.binding.local_variable_set(:tmp, nil)
289
- end
290
- end
291
-
292
- super
293
- ensure
294
- trace.disable
285
+ case rv = @io.read_nonblock(BUFSIZE, nil, exception: false)
286
+ when String
287
+ return if rv.nil?
288
+ @rbuf << rv
289
+ rv.clear
290
+ return
291
+ when :wait_readable
292
+ @io.to_io.wait_readable(@read_timeout) or raise Net::ReadTimeout
293
+ when :wait_writable
294
+ @io.to_io.wait_writable(@read_timeout) or raise Net::ReadTimeout
295
+ when nil
296
+ raise EOFError, 'end of file reached'
297
+ end while true
295
298
  end
296
299
  end
297
300
  end
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '3.8.0' unless defined?(::WebMock::VERSION)
2
+ VERSION = '3.8.1' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -74,13 +74,13 @@ describe "HTTP.rb" do
74
74
  context "streamer" do
75
75
  it "can be read to a provided buffer" do
76
76
  stub_request(:get, "example.com/foo")
77
- .to_return(status: 200, body: "Hello world!")
77
+ .to_return(status: 200, body: "Hello world!")
78
78
  response = HTTP.get "http://example.com/foo"
79
79
 
80
80
  buffer = ""
81
81
  response.body.readpartial(1024, buffer)
82
82
 
83
- expect(buffer).to eq "Hello world!"
83
+ expect(buffer).to eq "Hello world!"
84
84
  end
85
85
 
86
86
  it "can be closed" do
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.8.0
4
+ version: 3.8.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: 2020-01-14 00:00:00.000000000 Z
11
+ date: 2020-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -407,9 +407,9 @@ licenses:
407
407
  - MIT
408
408
  metadata:
409
409
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
410
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.8.0/CHANGELOG.md
411
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.8.0
412
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.8.0
410
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.8.1/CHANGELOG.md
411
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.8.1
412
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.8.1
413
413
  wiki_uri: https://github.com/bblimke/webmock/wiki
414
414
  post_install_message:
415
415
  rdoc_options: []
@@ -426,7 +426,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
426
426
  - !ruby/object:Gem::Version
427
427
  version: '0'
428
428
  requirements: []
429
- rubygems_version: 3.0.3
429
+ rubygems_version: 3.1.2
430
430
  signing_key:
431
431
  specification_version: 4
432
432
  summary: Library for stubbing HTTP requests in Ruby.