Class: Shoulda::Matchers::Doublespeak::ObjectDouble
- Inherits:
-
BasicObject
- Defined in:
- lib/shoulda/matchers/doublespeak/object_double.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ObjectDouble.
8
9
10
11
|
# File 'lib/shoulda/matchers/doublespeak/object_double.rb', line 8
def initialize
@calls = []
@calls_by_method_name = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/shoulda/matchers/doublespeak/object_double.rb', line 25
def method_missing(method_name, *args, &block)
call = MethodCall.new(
method_name: method_name,
args: args,
block: block,
caller: ::Kernel.caller,
)
calls << call
(calls_by_method_name[method_name] ||= []) << call
nil
end
|
Instance Attribute Details
#calls ⇒ Object
Returns the value of attribute calls.
6
7
8
|
# File 'lib/shoulda/matchers/doublespeak/object_double.rb', line 6
def calls
@calls
end
|
Instance Method Details
#calls_to(method_name) ⇒ Object
13
14
15
|
# File 'lib/shoulda/matchers/doublespeak/object_double.rb', line 13
def calls_to(method_name)
@calls_by_method_name[method_name] || []
end
|
#respond_to?(_name, _include_private = nil) ⇒ Boolean
17
18
19
|
# File 'lib/shoulda/matchers/doublespeak/object_double.rb', line 17
def respond_to?(_name, _include_private = nil)
true
end
|
#respond_to_missing?(_name, _include_all) ⇒ Boolean
21
22
23
|
# File 'lib/shoulda/matchers/doublespeak/object_double.rb', line 21
def respond_to_missing?(_name, _include_all)
true
end
|