module Protobuf::RSpec::Helpers::ClassMethods

Public Instance Methods

subject_service() { || ... } click to toggle source

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.

@example 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
# 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