Displaying 1 result from an estimated 1 matches for "anyobjectcomparator".
2008 Mar 08
3
should_receive(:foo).with(any_object)
...be
this is the first time where I can take something from Java to Ruby ;)
Java''s EasyMock mocking library knows things like "anyObject()" and
"anyInteger()" in their method equivalent  to should_receive. I like
the idea so I added this to my Rails spec_helper.rb:
class AnyObjectComparator
 attr_reader :object
 def ==(other)
   @object = other
   true
 end
end
class AnyNumberComparator <  AnyObjectComparator
 def ==(other)
   super.==(other)
   other.is_a?(Numeric)
 end
end
def any_object
 @any_object ||= AnyObjectComparator.new
 @any_object
end
def any_number
 @any_number ||=...