Created
February 13, 2014 10:57
-
-
Save Nerian/8973192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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:
Thanks guys!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The best I can think of is this:
Expectations have to be evaluated in order. If you do the above it will catch the first call to
tra
regardless of the args and then expect another call totra
with 2 as the arg.