protobuf-rspec 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,5 +2,6 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .rvmrc
5
6
  .yardoc
6
7
  doc
@@ -100,15 +100,17 @@ module Protobuf
100
100
  def local_rpc(rpc_method, request)
101
101
  request = subject_service.rpcs[rpc_method].request_type.new(request) if request.is_a?(Hash)
102
102
 
103
- outer_request_params = {
104
- :service_name => subject_service.to_s,
105
- :method_name => rpc_method.to_s,
103
+ outer_request_params = {
104
+ :service_name => subject_service.to_s,
105
+ :method_name => rpc_method.to_s,
106
106
  :request_proto => request.serialize_to_string
107
107
  }
108
108
 
109
109
  outer_request = ::Protobuf::Socketrpc::Request.new(outer_request_params)
110
110
  dispatcher = ::Protobuf::Rpc::ServiceDispatcher.new(outer_request)
111
111
 
112
+ yield(dispatcher.service) if block_given?
113
+
112
114
  dispatcher.invoke!
113
115
  end
114
116
 
@@ -228,8 +230,26 @@ module Protobuf
228
230
  alias_method :mock_service, :mock_rpc
229
231
  alias_method :mock_remote_service, :mock_rpc
230
232
 
231
- end
233
+ # Returns the request class for a given endpoint of the described class
234
+ #
235
+ # @example
236
+ # # With a create endpoint that takes a UserRequest object:
237
+ # request_class(:create) # => UserRequest
238
+ #
239
+ def request_class(endpoint)
240
+ subject_service.rpcs[endpoint].request_type
241
+ end
232
242
 
243
+ # Returns the response class for a given endpoint of the described class
244
+ #
245
+ # @example
246
+ # # With a create endpoint that takes a UserResponse object:
247
+ # response_class(:create) # => UserResponse
248
+ #
249
+ def response_class(endpoint)
250
+ subject_service.rpcs[endpoint].response_type
251
+ end
252
+ end
233
253
  end
234
254
  end
235
255
  end
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module RSpec
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-19 00:00:00.000000000Z
12
+ date: 2012-11-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: protobuf
16
- requirement: &2156886860 !ruby/object:Gem::Requirement
16
+ requirement: &2153155940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156886860
24
+ version_requirements: *2153155940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2156839100 !ruby/object:Gem::Requirement
27
+ requirement: &2153155220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.8'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156839100
35
+ version_requirements: *2153155220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2156838620 !ruby/object:Gem::Requirement
38
+ requirement: &2153154680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2156838620
46
+ version_requirements: *2153154680
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &2156837580 !ruby/object:Gem::Requirement
49
+ requirement: &2153153600 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.7'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2156837580
57
+ version_requirements: *2153153600
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: redcarpet
60
- requirement: &2156836540 !ruby/object:Gem::Requirement
60
+ requirement: &2153138880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '2.1'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2156836540
68
+ version_requirements: *2153138880
69
69
  description: Protobuf RSpec helpers for testing services and clients. Meant to be
70
70
  used with the protobuf gem. Decouple external services/clients from each other using
71
71
  the given helper methods.
@@ -97,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  segments:
99
99
  - 0
100
- hash: -1849475935849692850
100
+ hash: -3082988379435425688
101
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  none: false
103
103
  requirements:
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  segments:
108
108
  - 0
109
- hash: -1849475935849692850
109
+ hash: -3082988379435425688
110
110
  requirements: []
111
111
  rubyforge_project: protobuf-rspec
112
112
  rubygems_version: 1.8.15