Skip to content

Instantly share code, notes, and snippets.

@Nerian
Created February 13, 2014 10:57
Show Gist options
  • Save Nerian/8973192 to your computer and use it in GitHub Desktop.
Save Nerian/8973192 to your computer and use it in GitHub Desktop.
class MyTestClass
def cucu
tra(1)
tra(2)
end
def tra(args)
end
end
it "expect on the second", :focus do
ob = MyTestClass.new
expect(ob).to receive(:tra).with(2)
ob.cucu
end
@cupakromer
Copy link

Not sure if you'll see this, but if you do, you can create a "catch-all":

it "expect on the second", :focus do
  ob = MyTestClass.new

  allow(ob).to receive(:tra)  # catch all

  expect(ob).to receive(:tra).with(2)
  ob.cucu
end

I wrote a series on RSpec method matching:

@Nerian
Copy link
Author

Nerian commented Feb 17, 2014

Thanks guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment