Mock a static method on MyClass:
allow(MyClass).to receive(:my_method).with(1, 2, kind_of(Object)) { 'SOUNDS GOOD' }To fail if it doesn't get called, use expect instead of allow
To mock a method on any instances of MyClass:
expect_any_instance_of(MyClass).to receive(:some_method) { 'OK THEN' }An object that responds to things:
obj = double('optional-name').stub(get_five: 5, get_seven: 7)How to stub a method with another method
expect_any_instance_of(AdyenNotificationsController).to receive(:capture_exception) do |e, extra|
expect(e.message).to match(/Handling notifications of type BLAH is not implemented/)
end