grpc_mock 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/grpc_mock.gemspec +1 -1
- data/lib/grpc_mock/grpc_stub_adapter.rb +4 -4
- data/lib/grpc_mock/request_stub.rb +11 -3
- data/lib/grpc_mock/response.rb +34 -0
- data/lib/grpc_mock/{resopnse_sequence.rb → response_sequence.rb} +0 -0
- data/lib/grpc_mock/stub_registry.rb +1 -1
- data/lib/grpc_mock/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d717cdc98c3aa591bd9f3681b243c0fe51a80775d8ff2e3f6a4722c717aa0838
|
4
|
+
data.tar.gz: 2843c56fe8383a8d1bb1bacb2c5f64ed3d6f4342ea884052e1bdbf60aa063ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 394cf9c6dfd230e467d10d89933927cbec13273b11c4188358ffacba750dcd8df6eddfd4d546509411962d541c7d99118501d118acdedfbd0004c805d0d94937
|
7
|
+
data.tar.gz: d85fd1a0f7f73b94e35d8288648f264bb3c57b63a28d5135d3f9648589fc97d60244255741ea8e5e96b5934b7d2535d82ae49977cbf2db67f7e03ccad753b8d6
|
data/grpc_mock.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency 'grpc', '>= 1.12.0', '< 1.
|
25
|
+
spec.add_dependency 'grpc', '>= 1.12.0', '< 1.22.0'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'bundler'
|
28
28
|
spec.add_development_dependency 'grpc-tools'
|
@@ -15,7 +15,7 @@ module GrpcMock
|
|
15
15
|
|
16
16
|
mock = GrpcMock.stub_registry.response_for_request(method, request)
|
17
17
|
if mock
|
18
|
-
mock
|
18
|
+
mock.evaluate
|
19
19
|
elsif GrpcMock.config.allow_net_connect
|
20
20
|
super
|
21
21
|
else
|
@@ -32,7 +32,7 @@ module GrpcMock
|
|
32
32
|
r = requests.to_a # FIXME: this may not work
|
33
33
|
mock = GrpcMock.stub_registry.response_for_request(method, r)
|
34
34
|
if mock
|
35
|
-
mock
|
35
|
+
mock.evaluate
|
36
36
|
elsif GrpcMock.config.allow_net_connect
|
37
37
|
super
|
38
38
|
else
|
@@ -47,7 +47,7 @@ module GrpcMock
|
|
47
47
|
|
48
48
|
mock = GrpcMock.stub_registry.response_for_request(method, request)
|
49
49
|
if mock
|
50
|
-
mock
|
50
|
+
mock.evaluate
|
51
51
|
elsif GrpcMock.config.allow_net_connect
|
52
52
|
super
|
53
53
|
else
|
@@ -63,7 +63,7 @@ module GrpcMock
|
|
63
63
|
r = requests.to_a # FIXME: this may not work
|
64
64
|
mock = GrpcMock.stub_registry.response_for_request(method, r)
|
65
65
|
if mock
|
66
|
-
mock
|
66
|
+
mock.evaluate
|
67
67
|
elsif GrpcMock.config.allow_net_connect
|
68
68
|
super
|
69
69
|
else
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'grpc_mock/request_pattern'
|
4
|
-
require 'grpc_mock/
|
4
|
+
require 'grpc_mock/response'
|
5
|
+
require 'grpc_mock/response_sequence'
|
5
6
|
require 'grpc_mock/errors'
|
6
7
|
|
7
8
|
module GrpcMock
|
@@ -17,8 +18,15 @@ module GrpcMock
|
|
17
18
|
self
|
18
19
|
end
|
19
20
|
|
20
|
-
def to_return(*
|
21
|
-
|
21
|
+
def to_return(*values)
|
22
|
+
responses = [*values].flatten.map { |v| Response::Value.new(v) }
|
23
|
+
@response_sequence << GrpcMock::ResponsesSequence.new(responses)
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_raise(*exceptions)
|
28
|
+
responses = [*exceptions].flatten.map { |e| Response::ExceptionValue.new(e) }
|
29
|
+
@response_sequence << GrpcMock::ResponsesSequence.new(responses)
|
22
30
|
self
|
23
31
|
end
|
24
32
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GrpcMock
|
4
|
+
module Response
|
5
|
+
class ExceptionValue
|
6
|
+
def initialize(exception)
|
7
|
+
@exception = case exception
|
8
|
+
when String
|
9
|
+
StandardError.new(exception)
|
10
|
+
when Class
|
11
|
+
exception.new('Exception from GrpcMock')
|
12
|
+
when Exception
|
13
|
+
exception
|
14
|
+
else
|
15
|
+
raise ArgumentError.new(message: "Invalid exception class: #{exception.class}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def evaluate
|
20
|
+
raise @exception.dup
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Value
|
25
|
+
def initialize(value)
|
26
|
+
@value = value
|
27
|
+
end
|
28
|
+
|
29
|
+
def evaluate
|
30
|
+
@value.dup
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
File without changes
|
data/lib/grpc_mock/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc_mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuta Iwama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grpc
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 1.12.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
22
|
+
version: 1.22.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 1.12.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
32
|
+
version: 1.22.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,7 +142,8 @@ files:
|
|
142
142
|
- lib/grpc_mock/matchers/request_including_matcher.rb
|
143
143
|
- lib/grpc_mock/request_pattern.rb
|
144
144
|
- lib/grpc_mock/request_stub.rb
|
145
|
-
- lib/grpc_mock/
|
145
|
+
- lib/grpc_mock/response.rb
|
146
|
+
- lib/grpc_mock/response_sequence.rb
|
146
147
|
- lib/grpc_mock/rspec.rb
|
147
148
|
- lib/grpc_mock/stub_registry.rb
|
148
149
|
- lib/grpc_mock/version.rb
|