I would like to verify 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
Suddenly RSpec does not work:
expected :rec with (7) once, but received it 0 times
Any idea what is wrong with my approach? How to check efficient recursion with a specific argument?
ruby recursion mocking rspec
crispy
source share