Class: Gimme::TestDouble
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Gimme::TestDouble
- Defined in:
- lib/gimme/test_double.rb
Instance Attribute Summary collapse
-
#cls ⇒ Object
Returns the value of attribute cls.
-
#invocations ⇒ Object
readonly
Returns the value of attribute invocations.
-
#stubbings ⇒ Object
Returns the value of attribute stubbings.
Instance Method Summary collapse
-
#initialize(cls = nil) ⇒ TestDouble
constructor
A new instance of TestDouble.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(cls = nil) ⇒ TestDouble
Returns a new instance of TestDouble.
14 15 16 17 18 |
# File 'lib/gimme/test_double.rb', line 14 def initialize(cls=nil) @cls = cls @stubbings = {} @invocations = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gimme/test_double.rb', line 20 def method_missing(sym, *args, &block) sym = ResolvesMethods.new(self.cls,sym,args).resolve(false) @invocations[sym] ||= {} @stubbings[sym] ||= {} @invocations[sym][args] = 1 + (@invocations[sym][args]||0) InvokesSatisfiedStubbing.new(@stubbings).invoke(sym, args) end |
Instance Attribute Details
#cls ⇒ Object
Returns the value of attribute cls.
10 11 12 |
# File 'lib/gimme/test_double.rb', line 10 def cls @cls end |
#invocations ⇒ Object (readonly)
Returns the value of attribute invocations.
12 13 14 |
# File 'lib/gimme/test_double.rb', line 12 def invocations @invocations end |
#stubbings ⇒ Object
Returns the value of attribute stubbings.
11 12 13 |
# File 'lib/gimme/test_double.rb', line 11 def stubbings @stubbings end |