Ok I've been banging away it this problem for hours.
I am trying to mock out a call to a class and verify certain parameters match exactly, but not care about the others
So the class I am testing, lets call it SomethingElse
class SomethingElse
def blah
MyClass.new('SomeKey', 1234, Time.now)
end
end
So I have been doing this.
object = mock
MyClass.expects(:new).returns(object)
test_obj = SomethingElse.new
test_obj.blah
This works fine, but I want my test to verify those first two parameters on MyClass.new. I know what they must be, the third can be anything(just picking Time.now to make that clear)
I tried something like this, of course anything didn;'t work there.
MyClass.expects(:new).with("SomeKey", 1234, anything).returns(object)
Reading more, I thought includes might help. I tried
MyClass.expects(:new).with(includes("SomeKey", 1234)).returns(object)
But I got some error on converting integer to string. I've dug and tried all sorts of other things. I figure I am missing some simple aspect of this I am missing.
I am still pretty new to Mocha, so this is probably something dead simple...