grpc_mock 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: 9334a5bd9cda68e1129a4c3dbfee995761773d84
4
- data.tar.gz: 3af6df3d63c8b4fffc8bc40ba20e98e393b41d15
3
+ metadata.gz: fd11a8a9fe51756f230dd787fe6996643c68a7d4
4
+ data.tar.gz: 2f3567d682c7d6e934ba7a8ca4c1f64cc98f6fc9
5
5
  SHA512:
6
- metadata.gz: cab81764ab7ca1783b4b386319dd6ca9f3defc90a00b7d53a79435a5dbfb5d91eeb03a8eba5d7900bc931f168828e659c0839fecdcd0dce972c39fd608f51ee2
7
- data.tar.gz: 4fc6e418790551eaa69a26ca4a3e7c37e1a51de1217bf1f2210a86f4d45b90ef89535fb470f65ef69ca0b41250818df05cee758d3e0f0752a71601738ec78e8a
6
+ metadata.gz: 88dd0416c9169efe35bcb329eb6bb238458081adc70924f93e8d420b612f5aad88cc1aabd799ad010a672a990d03c584ba2aed3726c725963f0d3129ebf2e8ff
7
+ data.tar.gz: a1660786ac25573a5fb282b29fd31966cc9eedf0ee73a242f3df224a5109ff9088b49e723869ac4b3cab1bf1f954d7a9df8a1b3d398c2e002f80012dad44f75e
@@ -0,0 +1,7 @@
1
+ module GrpcMock
2
+ class NetConnectNotAllowedError < StandardError
3
+ def initialize(sigunature)
4
+ super("Real GRPC connections are disabled. #{sigunature} is requested")
5
+ end
6
+ end
7
+ end
@@ -1,4 +1,5 @@
1
1
  require 'grpc'
2
+ require 'grpc_mock/errors'
2
3
 
3
4
  module GrpcMock
4
5
  class GrpcStubAdapter
@@ -17,29 +18,37 @@ module GrpcMock
17
18
  def request_response(method, req, marshal, unmarshal, **opt)
18
19
  if GrpcMock.config.allow_net_connect
19
20
  original_request_response(method, req, marshal, unmarshal, **opt)
21
+ else
22
+ raise NetConnectNotAllowedError, method
20
23
  end
21
24
  end
22
25
 
23
26
  def client_streamer(method, requests, marshal, unmarshal, **opt)
24
27
  if GrpcMock.config.allow_net_connect
25
28
  original_client_streamer(method, requests, marshal, unmarshal, **opt)
29
+ else
30
+ raise NetConnectNotAllowedError, method
26
31
  end
27
32
  end
28
33
 
29
34
  def server_streamer(method, req, marshal, unmarshal, **opt)
30
35
  if GrpcMock.config.allow_net_connect
31
36
  original_server_streamer(method, req, marshal, unmarshal, **opt)
37
+ else
38
+ raise NetConnectNotAllowedError, method
32
39
  end
33
40
  end
34
41
 
35
42
  def bidi_streamer(method, requests, marshal, unmarshal, **opt)
36
43
  if GrpcMock.config.allow_net_connect
37
44
  original_bidi_streamer(method, requests, marshal, unmarshal, **opt)
45
+ else
46
+ raise NetConnectNotAllowedError, method
38
47
  end
39
48
  end
40
49
  end
41
50
 
42
- # This class is only use for disabling grpc_stub_adapter hook
51
+ # This class is only used for disabling grpc_stub_adapter hook
43
52
  THROUGHT_CLASS = Module.new do
44
53
  def request_response(method, req, marshal, unmarshal, **opt)
45
54
  original_request_response(method, req, marshal, unmarshal, **opt)
@@ -1,3 +1,3 @@
1
1
  module GrpcMock
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grpc_mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ganmacs
@@ -130,6 +130,7 @@ files:
130
130
  - lib/grpc_mock.rb
131
131
  - lib/grpc_mock/adapter.rb
132
132
  - lib/grpc_mock/configure.rb
133
+ - lib/grpc_mock/errors.rb
133
134
  - lib/grpc_mock/grpc_stub_adapter.rb
134
135
  - lib/grpc_mock/rspec.rb
135
136
  - lib/grpc_mock/version.rb