2014-04-20 00:01:22 +00:00
|
|
|
module Shoulda
|
|
|
|
module Matchers
|
|
|
|
module Doublespeak
|
2014-01-23 18:07:36 +00:00
|
|
|
# @private
|
2014-04-20 00:01:22 +00:00
|
|
|
class ObjectDouble < BasicObject
|
|
|
|
attr_reader :calls
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
@calls = []
|
|
|
|
@calls_by_method_name = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def calls_to(method_name)
|
|
|
|
@calls_by_method_name[method_name] || []
|
|
|
|
end
|
|
|
|
|
|
|
|
def respond_to?(name, include_private = nil)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def method_missing(method_name, *args, &block)
|
|
|
|
calls << MethodCallWithName.new(method_name, args, block)
|
|
|
|
(calls_by_method_name[method_name] ||= []) << MethodCall.new(args, block)
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2014-06-24 15:57:52 +00:00
|
|
|
protected
|
2014-04-20 00:01:22 +00:00
|
|
|
|
|
|
|
attr_reader :calls_by_method_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|