Class: Gimme::TestDouble

Inherits:
BlankSlate show all
Defined in:
lib/gimme/test_double.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cls = nil) ⇒ TestDouble

Returns a new instance of TestDouble.



12
13
14
# File 'lib/gimme/test_double.rb', line 12

def initialize(cls=nil)
  @cls = cls
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



16
17
18
19
20
# File 'lib/gimme/test_double.rb', line 16

def method_missing(method, *args, &block)
  method = ResolvesMethods.new(self.cls, method, args).resolve(false)
  Gimme.invocations.increment(self, method, args)
  InvokesSatisfiedStubbing.new(Gimme.stubbings.get(self)).invoke(method, args)
end

Instance Attribute Details

#clsObject

Returns the value of attribute cls.



10
11
12
# File 'lib/gimme/test_double.rb', line 10

def cls
  @cls
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/gimme/test_double.rb', line 30

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:



26
27
28
# File 'lib/gimme/test_double.rb', line 26

def eql?(other)
  __id__ == other.__id__
end

#hashObject



22
23
24
# File 'lib/gimme/test_double.rb', line 22

def hash
  __id__
end