Module: Protobuf::RSpec::Helpers::ClassMethods

Defined in:
lib/protobuf/rspec/helpers.rb

Instance Method Summary collapse

Instance Method Details

#subject_serviceObject

Set the service subject. Use this method when the described_class is not the class you wish to use with methods like local_rpc, request_class, or response_class.

Examples:

Override subject service for local_rpc calls

describe Foo::BarService do
  # Use Foo::BazService instead of Foo::BarService
  subject_service { Foo::BazService }

  subject { local_rpc(:find, request) }
  its('response.records') { should have(3).items }
end


38
39
40
41
42
43
44
# File 'lib/protobuf/rspec/helpers.rb', line 38

def subject_service
  if block_given?
    @_subject_service = yield
  else
    defined?(@_subject_service) ? @_subject_service : described_class
  end
end