webmock-twirp 0.4.0 → 0.4.2

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: 292380b89f2b938b849edb2e4ce46cb84e197b6a39592d16425440446adce9a1
4
- data.tar.gz: 64be8b4452a96b256adc5bfe9d08a479392d9cb916f4fe0ab1135cc763728f87
3
+ metadata.gz: 607a11741909a668d93abbf06cc7c1a63f2be283230c46f2bc9ca3fc230cb747
4
+ data.tar.gz: 6ebdf1ef48c0886b5c0dda1db1bad290295b7efe52115a28dfaca66dec2ff1df
5
5
  SHA512:
6
- metadata.gz: c4f52185995140dc0d2aa2646227bbd9195a87941a1ab40a20d6e1dfb1b29bf24c9b0a50796db26fecd453f802fecc5bd5003eee284f325ccea3a96bf4f152a6
7
- data.tar.gz: fa2e3ed00ed69f960dae3c500979fc8a745cd6e78015c68d6b963ee85ffad842070855abcdd8d50e6f37263f2789ead2f231d50092698c496bd0e4e5b8251970
6
+ metadata.gz: a9166fa3477ecc944b0b726f7391307c9c75a5aa50a93ae20aa43f8a3d3af82bf536a4a9b949a7ae757ed27655a650b7b641d956a25ad6d3f5bd87516e478798
7
+ data.tar.gz: c0c2eb90b95a0eb0039772fccc7053e9c19170e38c34f6d002c83edb779b544ef555b827d0c49e8f36b5c4df9ac4780db89540d8759c55e8de4534dc0d2b0295
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ### v0.4.2 (2023-04-05)
2
+ - ruby 2 compatibility
3
+ - twirp 1.10 compatibility
4
+
5
+ ### v0.4.1 (2022-12-15)
6
+ - protobuf type support
7
+ - gemspec cleanup
8
+ - build upgrade
9
+ - dependabot
10
+ - respond to improvement
11
+
1
12
  ### v0.4.0 (2022-11-16)
2
13
  - .to_return(Twirp::ClientResp)
3
14
  - revert client class name filter
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,73 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ webmock-twirp (0.4.2)
5
+ twirp (>= 1)
6
+ webmock (>= 3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.3)
12
+ public_suffix (>= 2.0.2, < 6.0)
13
+ byebug (11.1.3)
14
+ codecov (0.2.12)
15
+ json
16
+ simplecov
17
+ crack (0.4.5)
18
+ rexml
19
+ diff-lcs (1.5.0)
20
+ docile (1.4.0)
21
+ faraday (2.7.4)
22
+ faraday-net_http (>= 2.0, < 3.1)
23
+ ruby2_keywords (>= 0.0.4)
24
+ faraday-net_http (3.0.2)
25
+ google-protobuf (3.22.2)
26
+ hashdiff (1.0.1)
27
+ json (2.6.3)
28
+ public_suffix (5.0.1)
29
+ rack (3.0.7)
30
+ rexml (3.2.5)
31
+ rspec (3.12.0)
32
+ rspec-core (~> 3.12.0)
33
+ rspec-expectations (~> 3.12.0)
34
+ rspec-mocks (~> 3.12.0)
35
+ rspec-core (3.12.0)
36
+ rspec-support (~> 3.12.0)
37
+ rspec-expectations (3.12.0)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.12.0)
40
+ rspec-mocks (3.12.1)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.12.0)
43
+ rspec-support (3.12.0)
44
+ ruby2_keywords (0.0.5)
45
+ simplecov (0.22.0)
46
+ docile (~> 1.1)
47
+ simplecov-html (~> 0.11)
48
+ simplecov_json_formatter (~> 0.1)
49
+ simplecov-html (0.12.3)
50
+ simplecov_json_formatter (0.1.4)
51
+ twirp (1.10.0)
52
+ faraday (< 3)
53
+ google-protobuf (~> 3.0, >= 3.7.0)
54
+ webmock (3.18.1)
55
+ addressable (>= 2.8.0)
56
+ crack (>= 0.3.2)
57
+ hashdiff (>= 0.4.0, < 2.0.0)
58
+ webrick (1.8.1)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ byebug
65
+ codecov
66
+ rack
67
+ rspec
68
+ simplecov
69
+ webmock-twirp!
70
+ webrick
71
+
72
+ BUNDLED WITH
73
+ 2.3.17
data/README.md CHANGED
@@ -44,6 +44,8 @@ stub_twirp_request.and_return do |request|
44
44
  end
45
45
  ```
46
46
 
47
+ For additional RSpec support, see [rspec-twirp](https://github.com/dpep/rspec-twirp).
48
+
47
49
 
48
50
  ## Usage
49
51
 
@@ -7,14 +7,14 @@ module WebMock
7
7
  end
8
8
 
9
9
  def method_missing(name, *args, **kwargs, &block)
10
- super unless respond_to?(name)
10
+ return super unless respond_to_missing?(name)
11
11
  @stub.send(name, *args, **kwargs, &block)
12
12
 
13
13
  self
14
14
  end
15
15
 
16
- def respond_to?(method_name, include_private = false)
17
- super || @stub.respond_to?(method_name)
16
+ def respond_to_missing?(method_name, include_private = false)
17
+ @stub.respond_to?(method_name)
18
18
  end
19
19
 
20
20
  def matches?(block)
@@ -77,6 +77,12 @@ module WebMock
77
77
  raise ArgumentError, "specify request or attrs, but not both"
78
78
  end
79
79
 
80
+ # support Ruby 2 style attributes-as-hash instead of kwargs
81
+ if request.is_a?(Hash)
82
+ attrs = request
83
+ request = nil
84
+ end
85
+
80
86
  request_matcher = if request
81
87
  unless request.is_a?(Google::Protobuf::MessageExts)
82
88
  raise TypeError, "Expected request to be Protobuf::MessageExts, found: #{request}"
@@ -182,6 +188,12 @@ module WebMock
182
188
  else
183
189
  raise ArgumentError, "invalid http error status: #{obj}"
184
190
  end
191
+ when Class
192
+ unless obj == msg_class
193
+ raise TypeError, "Expected type #{msg_class}, found #{obj}"
194
+ end
195
+
196
+ obj.new
185
197
  else
186
198
  raise ArgumentError, "can not generate twirp reponse from: #{obj}"
187
199
  end
@@ -1,5 +1,5 @@
1
1
  module WebMock
2
2
  module Twirp
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.2"
4
4
  end
5
5
  end
data/service.rb ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "google/protobuf"
4
+ require "rack"
5
+ require "twirp"
6
+ require "webrick"
7
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
8
+
9
+ server = WEBrick::HTTPServer.new(Port: 3000)
10
+
11
+ handler = EchoHandler.new
12
+ service = EchoService.new(handler)
13
+ path_prefix = "/twirp/" + service.full_name
14
+ server.mount path_prefix, Rack::Handler::WEBrick, service
15
+
16
+ # handler = ComplexHandler.new
17
+ # service = ComplexService.new(handler)
18
+ # path_prefix = "/twirp/" + service.full_name
19
+ # server.mount path_prefix, Rack::Handler::WEBrick, service
20
+
21
+ server.start
22
+
23
+ # client = EchoClient.new("http://localhost:3000/twirp")
24
+ # client = ComplexClient.new("http://localhost:3000/twirp")
25
+ # resp = client.echo(msg: "World")
26
+ # puts resp.data
@@ -1,25 +1,15 @@
1
- package_name = File.basename(__FILE__).split(".")[0]
2
- load Dir.glob("lib/**/version.rb")[0]
3
-
1
+ require_relative "lib/webmock/twirp/version"
4
2
  package = WebMock::Twirp
5
3
 
6
-
7
4
  Gem::Specification.new do |s|
8
- s.name = package_name
9
- s.version = package.const_get "VERSION"
10
5
  s.authors = ["Daniel Pepper"]
11
- s.summary = package.to_s
12
6
  s.description = "Twirp support for WebMock"
13
- s.homepage = "https://github.com/dpep/#{package_name}"
7
+ s.files = `git ls-files * ':!:spec'`.split("\n")
8
+ s.homepage = "https://github.com/dpep/webmock-twirp"
14
9
  s.license = "MIT"
15
-
16
- s.files = Dir[
17
- __FILE__,
18
- 'lib/**/*',
19
- 'CHANGELOG*',
20
- 'LICENSE*',
21
- 'README*',
22
- ]
10
+ s.name = File.basename(__FILE__).split(".")[0]
11
+ s.summary = package.to_s
12
+ s.version = package.const_get "VERSION"
23
13
 
24
14
  s.add_dependency "webmock", ">= 3"
25
15
  s.add_dependency "twirp", ">= 1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock-twirp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-16 00:00:00.000000000 Z
11
+ date: 2023-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webmock
@@ -129,6 +129,8 @@ extensions: []
129
129
  extra_rdoc_files: []
130
130
  files:
131
131
  - CHANGELOG.md
132
+ - Gemfile
133
+ - Gemfile.lock
132
134
  - LICENSE.txt
133
135
  - README.md
134
136
  - lib/webmock-twirp.rb
@@ -143,6 +145,7 @@ files:
143
145
  - lib/webmock/twirp/request_stub.rb
144
146
  - lib/webmock/twirp/stub_request_snippet.rb
145
147
  - lib/webmock/twirp/version.rb
148
+ - service.rb
146
149
  - webmock-twirp.gemspec
147
150
  homepage: https://github.com/dpep/webmock-twirp
148
151
  licenses:
@@ -166,5 +169,5 @@ requirements: []
166
169
  rubygems_version: 3.3.7
167
170
  signing_key:
168
171
  specification_version: 4
169
- summary: Gem::Specification::WebMock::Twirp
172
+ summary: WebMock::Twirp
170
173
  test_files: []