I'd like to test that a method is called recursively with a specific argument.
My approach:
class Recursable
def rec(arg)
rec(7) unless arg == 7
end
end
describe Recursable do
it "should recurse" do
r = Recursable.new('test')
r.should_receive(:rec).with(0).ordered
r.should_receive(:rec).with(7).ordered
r.rec(0)
end
end
Unexpectedly, RSpec fails with:
expected :rec with (7) once, but received it 0 times
Any idea what's wrong with my approach? How to test for effective recursion with a specific argument?