Read more

RSpec: Only stub a method when a particular argument is passed

Henning Koch
January 29, 2015Software engineer at makandra GmbH

To only stub a method call if a given argument is used, but use the default implementation for other arguments:

object.should_receive(:some_method).and_call_original
object.should_receive(:some_method).with('my argument').and_return('other value')
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

Requires rspec-mocks 2.13+.

Posted by Henning Koch to makandra dev (2015-01-29 10:38)