Module: RepositoryStubber
- Defined in:
- lib/generators/rider_kick/templates/spec/support/repository_stubber.rb
Instance Method Summary collapse
Instance Method Details
#stub_repository(repository:, expected_output:, response: :success, params: nil) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/generators/rider_kick/templates/spec/support/repository_stubber.rb', line 4 def stub_repository(repository:, expected_output:, response: :success, params: nil) monads = response.to_s.eql?('success') ? Dry::Monads::Success(expected_output) : Dry::Monads::Failure(expected_output) expectation = allow(repository).to receive(:new) expectation.with(params) if params expectation.and_return(instance_double(repository, call: monads)) end |