Class: LcpRuby::Authentication::TestSupport::Stubber

Inherits:
Object
  • Object
show all
Includes:
RSpec::Mocks::ExampleMethods
Defined in:
lib/lcp_ruby/authentication/test_support.rb

Overview

Thin wrapper over RSpec::Mocks::ExampleMethods. Keeps mock primitives out of the TestSupport public surface.

Instance Method Summary collapse

Instance Method Details

#stub_return(target, method_name, value) ⇒ Object



181
182
183
# File 'lib/lcp_ruby/authentication/test_support.rb', line 181

def stub_return(target, method_name, value)
  allow(target).to receive(method_name).and_return(value)
end

#stub_with_args(target, method_name, args:, kwargs: nil, return_value:) ⇒ Object



185
186
187
188
189
190
191
192
193
# File 'lib/lcp_ruby/authentication/test_support.rb', line 185

def stub_with_args(target, method_name, args:, kwargs: nil, return_value:)
  stub = allow(target).to receive(method_name)
  stub = if kwargs
    stub.with(*args, **kwargs)
  else
    stub.with(*args)
  end
  stub.and_return(return_value)
end