webmock-twirp 0.5.0 → 0.6.0

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: bbad5503c5dd1bde8669aecc1119f73c79b709ac1cb6075c664866ecd9d2f27c
4
- data.tar.gz: 7c3ee3cb14d758a6d4a75abefd6d4a87301a2176baa351f78339532252944f2d
3
+ metadata.gz: 4d2e3419ce5ddc60c10c14e7cb33e806b6ee92c0f93787b5209a0e3eeb47638e
4
+ data.tar.gz: 84b5215a00b57a531f24fde3298b0720bba7de7fd0553523af3ac3bd3df83cbf
5
5
  SHA512:
6
- metadata.gz: f185ac5c5a58f9188770b0ac787ef5d11c1a1d665b1f8cc1e33befcd27399b60adc645df990caa2368fbd354eec224397f63f06c1154d3039db487cc555193ea
7
- data.tar.gz: d24dd405de783c33a2a7c5aba2fe27a8208bccd1b613c91cb75618103a54437e1e88bdb609efaddfe89ebdb0b197c876bb305c8475f753c925e010ca35c5c35a
6
+ metadata.gz: 59acbce84012d937a66f6fe601a2ec0b49f9a56c384113c35371362b603907f201dea384f54e343e8759b9b397c732f8c03e185d2a72ab88f7bfb33ba5e3fa4b
7
+ data.tar.gz: 536a0a49c744b98d3973e56c18e02ec0e968f14f71639ee4164808b6a07f545a6df416ee1b7e36b11bf877e8febad5163b634fe10a4d7fc3bfe9ddf6c1624f52
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 0.6.0 (2025-02-11)
2
+ - rspec matcher support
3
+ - debug gem
4
+
5
+ ### v0.5.1 (2024-04-17)
6
+ - fix rpc name matching
7
+
1
8
  ### v0.5.0 (2024-04-07)
2
9
  - codecov upgrade
3
10
  - drop ruby 2.7 (#65)
data/Gemfile.lock CHANGED
@@ -1,67 +1,91 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webmock-twirp (0.5.0)
4
+ webmock-twirp (0.6.0)
5
5
  twirp (>= 1)
6
6
  webmock (>= 3)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.8.6)
12
- public_suffix (>= 2.0.2, < 6.0)
13
- base64 (0.2.0)
14
- bigdecimal (3.1.6)
15
- byebug (11.1.3)
11
+ addressable (2.8.7)
12
+ public_suffix (>= 2.0.2, < 7.0)
13
+ bigdecimal (3.1.9)
16
14
  crack (1.0.0)
17
15
  bigdecimal
18
16
  rexml
17
+ date (3.4.1)
18
+ debug (1.10.0)
19
+ irb (~> 1.10)
20
+ reline (>= 0.3.8)
19
21
  diff-lcs (1.5.1)
20
- docile (1.4.0)
21
- faraday (2.7.11)
22
- base64
23
- faraday-net_http (>= 2.0, < 3.1)
24
- ruby2_keywords (>= 0.0.4)
25
- faraday-net_http (3.0.2)
22
+ docile (1.4.1)
23
+ faraday (2.12.1)
24
+ faraday-net_http (>= 2.0, < 3.5)
25
+ json
26
+ logger
27
+ faraday-net_http (3.4.0)
28
+ net-http (>= 0.5.0)
26
29
  google-protobuf (3.25.3)
27
- hashdiff (1.1.0)
28
- public_suffix (5.0.4)
29
- rack (3.0.10)
30
- rexml (3.2.6)
30
+ hashdiff (1.1.2)
31
+ io-console (0.8.0)
32
+ irb (1.15.1)
33
+ pp (>= 0.6.0)
34
+ rdoc (>= 4.0.0)
35
+ reline (>= 0.4.2)
36
+ json (2.9.0)
37
+ logger (1.6.2)
38
+ net-http (0.6.0)
39
+ uri
40
+ pp (0.6.2)
41
+ prettyprint
42
+ prettyprint (0.2.0)
43
+ psych (5.2.3)
44
+ date
45
+ stringio
46
+ public_suffix (6.0.1)
47
+ rack (3.1.9)
48
+ rdoc (6.12.0)
49
+ psych (>= 4.0.0)
50
+ reline (0.6.0)
51
+ io-console (~> 0.5)
52
+ rexml (3.4.0)
31
53
  rspec (3.13.0)
32
54
  rspec-core (~> 3.13.0)
33
55
  rspec-expectations (~> 3.13.0)
34
56
  rspec-mocks (~> 3.13.0)
35
- rspec-core (3.13.0)
57
+ rspec-core (3.13.2)
36
58
  rspec-support (~> 3.13.0)
37
- rspec-expectations (3.13.0)
59
+ rspec-expectations (3.13.3)
38
60
  diff-lcs (>= 1.2.0, < 2.0)
39
61
  rspec-support (~> 3.13.0)
40
- rspec-mocks (3.13.0)
62
+ rspec-mocks (3.13.2)
41
63
  diff-lcs (>= 1.2.0, < 2.0)
42
64
  rspec-support (~> 3.13.0)
43
- rspec-support (3.13.0)
44
- ruby2_keywords (0.0.5)
65
+ rspec-support (3.13.2)
45
66
  simplecov (0.22.0)
46
67
  docile (~> 1.1)
47
68
  simplecov-html (~> 0.11)
48
69
  simplecov_json_formatter (~> 0.1)
49
- simplecov-html (0.12.3)
70
+ simplecov-html (0.13.1)
50
71
  simplecov_json_formatter (0.1.4)
51
- twirp (1.10.0)
72
+ stringio (3.1.2)
73
+ twirp (1.13.0)
52
74
  faraday (< 3)
53
- google-protobuf (~> 3.0, >= 3.7.0)
54
- webmock (3.23.0)
75
+ google-protobuf (>= 3.25, < 5.a)
76
+ rack (>= 2.2.3)
77
+ uri (1.0.2)
78
+ webmock (3.25.0)
55
79
  addressable (>= 2.8.0)
56
80
  crack (>= 0.3.2)
57
81
  hashdiff (>= 0.4.0, < 2.0.0)
58
- webrick (1.8.1)
82
+ webrick (1.9.1)
59
83
 
60
84
  PLATFORMS
61
85
  ruby
62
86
 
63
87
  DEPENDENCIES
64
- byebug
88
+ debug
65
89
  rack
66
90
  rspec
67
91
  simplecov
@@ -61,14 +61,7 @@ module WebMock
61
61
  # match rpc dynamically after client resolves
62
62
  @rpc_name = rpc_name
63
63
 
64
- @request_pattern.with do |request|
65
- rpc_info = request.twirp_rpc
66
-
67
- !!rpc_info && (
68
- rpc_info[:rpc_method] == rpc_name ||
69
- rpc_info[:ruby_method] == rpc_name
70
- )
71
- end
64
+ with
72
65
  end
73
66
  end
74
67
 
@@ -84,11 +77,20 @@ module WebMock
84
77
  end
85
78
 
86
79
  request_matcher = if request
87
- unless request.is_a?(Google::Protobuf::MessageExts)
88
- raise TypeError, "Expected request to be Protobuf::MessageExts, found: #{request}"
80
+ if request.is_a?(Google::Protobuf::MessageExts)
81
+ # match message type and contents
82
+ # RSpec::Matchers::BuiltIn::Eq.new(request)
83
+ ->(expected, actual) { actual == expected }.curry.call(request)
84
+ elsif request.is_a?(Class) && request < Google::Protobuf::MessageExts
85
+ # match message type
86
+ # RSpec::Matchers::BuiltIn::BeAKindOf.new(request)
87
+ ->(expected, actual) { actual.is_a?(expected) }.curry.call(request)
88
+ elsif request.respond_to?(:matches?)
89
+ # is_a?(RSpec::Matchers::BuiltIn::BaseMatcher)
90
+ ->(expected, actual) { expected.matches?(actual) }.curry.call(request)
91
+ else
92
+ raise TypeError, "Expected request to be a Protobuf::MessageExts, found: #{request}"
89
93
  end
90
-
91
- { body: request.to_proto }
92
94
  end
93
95
 
94
96
  # save for diffing
@@ -100,12 +102,26 @@ module WebMock
100
102
  attrs
101
103
  end
102
104
 
103
- decoder = ->(request_signature) do
105
+ super() do |request_signature|
104
106
  matched = true
105
107
 
106
108
  request = request_signature.twirp_request
107
109
  matched &&= !!request
108
110
 
111
+ if request_matcher
112
+ matched &&= request_matcher.call(request)
113
+ end
114
+
115
+ # match rpc_name
116
+ if @rpc_name
117
+ rpc_info = request_signature.twirp_rpc
118
+
119
+ matched &&= !!rpc_info && (
120
+ rpc_info[:rpc_method] == @rpc_name ||
121
+ rpc_info[:ruby_method] == @rpc_name
122
+ )
123
+ end
124
+
109
125
  # match request attributes
110
126
  if attrs.any?
111
127
  matched &&= request.include?(attrs)
@@ -116,8 +132,6 @@ module WebMock
116
132
 
117
133
  matched
118
134
  end
119
-
120
- super(request_matcher || {}, &decoder)
121
135
  end
122
136
 
123
137
  def to_return(*responses, &block)
@@ -195,7 +209,7 @@ module WebMock
195
209
 
196
210
  obj.new
197
211
  else
198
- raise ArgumentError, "can not generate twirp reponse from: #{obj}"
212
+ raise ArgumentError, "can not generate twirp response from: #{obj}"
199
213
  end
200
214
 
201
215
  if res.is_a?(Google::Protobuf::MessageExts)
@@ -1,5 +1,5 @@
1
1
  module WebMock
2
2
  module Twirp
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency "webmock", ">= 3"
17
17
  s.add_dependency "twirp", ">= 1"
18
18
 
19
- s.add_development_dependency "byebug"
19
+ s.add_development_dependency "debug"
20
20
  s.add_development_dependency "rack"
21
21
  s.add_development_dependency "rspec"
22
22
  s.add_development_dependency "simplecov"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock-twirp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-04-07 00:00:00.000000000 Z
10
+ date: 2025-02-11 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: webmock
@@ -39,7 +38,7 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '1'
41
40
  - !ruby/object:Gem::Dependency
42
- name: byebug
41
+ name: debug
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - ">="
@@ -109,7 +108,6 @@ dependencies:
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  description: Twirp support for WebMock
112
- email:
113
111
  executables: []
114
112
  extensions: []
115
113
  extra_rdoc_files: []
@@ -137,7 +135,6 @@ homepage: https://github.com/dpep/webmock-twirp
137
135
  licenses:
138
136
  - MIT
139
137
  metadata: {}
140
- post_install_message:
141
138
  rdoc_options: []
142
139
  require_paths:
143
140
  - lib
@@ -152,8 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
149
  - !ruby/object:Gem::Version
153
150
  version: '0'
154
151
  requirements: []
155
- rubygems_version: 3.5.7
156
- signing_key:
152
+ rubygems_version: 3.6.3
157
153
  specification_version: 4
158
154
  summary: WebMock::Twirp
159
155
  test_files: []