webmock 3.19.0 → 3.19.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: 57ade97b45c0a5c72d60b74f83afd38ff397fd878c43e02de7e7d148e1d1ace8
4
- data.tar.gz: b8c6e112eb3eec3d0f5bcaff76c6c8209d84eeb71f625bedfebc63b1fe6756f2
3
+ metadata.gz: 379567500380d6df66bea0edab72f977ddbcab8fc2cc79f9c2e4c535c46cfeb4
4
+ data.tar.gz: fbab14a1e3a2d7a5563f293e735f521dc47481e7d574f4ace0e5cefa9a15fb8e
5
5
  SHA512:
6
- metadata.gz: de9230ccdbfaa25cc814d9ffa1091edf85d279e1982728e64d7c721355897d8eb2a0bd3ad94eff36917f0d696287edc8218d3882255bcc6234393f90c084c28b
7
- data.tar.gz: 58d85aeb70b455fc02322c0f868e4937cc4d93b9db0c0a3dd9fede8b08bebf8adf2a7d9a0aebb3e1e40a52b079d8841530075ecef203ff16a937a20954b50861
6
+ metadata.gz: 768bc4817766c1b5d2c799c8453bf59411d69f36c4d3b6dfc0630f2a830efa4b72b78dd999cce146bf8f4754a05fbd0dbbddcc72a7389f8b48b8546d4d98dba0
7
+ data.tar.gz: ca14f9cffef86ef82b52985f5ad58f662cbffcb33b86050ffd6e9390efaf5892eed0469595f153d7b0d8a8e6141a75a1e47cdd8076178385a92fe99593c8b3c3
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  # 3.19.0
4
4
 
5
+ * When passing a Proc or lambda as response body to `to_return_json`, the body is evaluated at the time of request and not at the time of `to_return_json` method invocation.
6
+
7
+ Thanks to [Jason Karns](https://github.com/jasonkarns) for reporting.
8
+
5
9
  * Do not alter real (non-stubbed) request headers when handling em-http-request requests.
6
10
 
7
11
  Thanks to [Yoann Lecuyer](https://github.com/ylecuyer)
@@ -32,12 +32,25 @@ module WebMock
32
32
  json_response_hashes = [*response_hashes].flatten.map do |resp_h|
33
33
  headers, body = resp_h.values_at(:headers, :body)
34
34
 
35
- body = body.call if body.respond_to?(:call)
36
- body = body.to_json unless body.is_a?(String)
35
+ json_body = if body.respond_to?(:call)
36
+ ->(request_signature) {
37
+ b = if body.respond_to?(:arity) && body.arity == 1
38
+ body.call(request_signature)
39
+ else
40
+ body.call
41
+ end
42
+ b = b.to_json unless b.is_a?(String)
43
+ b
44
+ }
45
+ elsif !body.is_a?(String)
46
+ body.to_json
47
+ else
48
+ body
49
+ end
37
50
 
38
51
  resp_h.merge(
39
52
  headers: {content_type: 'application/json'}.merge(headers.to_h),
40
- body: body
53
+ body: json_body
41
54
  )
42
55
  end
43
56
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebMock
4
- VERSION = '3.19.0' unless defined?(::WebMock::VERSION)
4
+ VERSION = '3.19.1' unless defined?(::WebMock::VERSION)
5
5
  end
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.19.0
4
+ version: 3.19.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: 2023-08-26 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -357,9 +357,9 @@ licenses:
357
357
  - MIT
358
358
  metadata:
359
359
  bug_tracker_uri: https://github.com/bblimke/webmock/issues
360
- changelog_uri: https://github.com/bblimke/webmock/blob/v3.19.0/CHANGELOG.md
361
- documentation_uri: https://www.rubydoc.info/gems/webmock/3.19.0
362
- source_code_uri: https://github.com/bblimke/webmock/tree/v3.19.0
360
+ changelog_uri: https://github.com/bblimke/webmock/blob/v3.19.1/CHANGELOG.md
361
+ documentation_uri: https://www.rubydoc.info/gems/webmock/3.19.1
362
+ source_code_uri: https://github.com/bblimke/webmock/tree/v3.19.1
363
363
  wiki_uri: https://github.com/bblimke/webmock/wiki
364
364
  post_install_message:
365
365
  rdoc_options: []
@@ -376,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
376
  - !ruby/object:Gem::Version
377
377
  version: '0'
378
378
  requirements: []
379
- rubygems_version: 3.4.10
379
+ rubygems_version: 3.4.19
380
380
  signing_key:
381
381
  specification_version: 4
382
382
  summary: Library for stubbing HTTP requests in Ruby.