Skip to content

Commit

Permalink
Merge pull request #5 from liveh2o/master
Browse files Browse the repository at this point in the history
Add request_class and response_class to return proto type for subject_service
  • Loading branch information
localshred committed Nov 20, 2012
2 parents 6a55335 + 9d46f1e commit c81901c
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/protobuf/rspec/helpers.rb
Expand Up @@ -100,9 +100,9 @@ def subject_service
def local_rpc(rpc_method, request)
request = subject_service.rpcs[rpc_method].request_type.new(request) if request.is_a?(Hash)

outer_request_params = {
:service_name => subject_service.to_s,
:method_name => rpc_method.to_s,
outer_request_params = {
:service_name => subject_service.to_s,
:method_name => rpc_method.to_s,
:request_proto => request.serialize_to_string
}

Expand Down Expand Up @@ -230,8 +230,26 @@ def mock_rpc(klass, method, callbacks={}, &assert_block)
alias_method :mock_service, :mock_rpc
alias_method :mock_remote_service, :mock_rpc

end
# Returns the request class for a given endpoint of the described class
#
# @example
# # With a create endpoint that takes a UserRequest object:
# request_class(:create) # => UserRequest
#
def request_class(endpoint)
subject_service.rpcs[endpoint].request_type
end

# Returns the response class for a given endpoint of the described class
#
# @example
# # With a create endpoint that takes a UserResponse object:
# response_class(:create) # => UserResponse
#
def response_class(endpoint)
subject_service.rpcs[endpoint].response_type
end
end
end
end
end

0 comments on commit c81901c

Please sign in to comment.