Class: Mocks::Mock

Inherits:
Object show all
Includes:
Abstract
Defined in:
lib/mocks/mock.rb

Direct Known Subclasses

MethodLogger, Object, Observer

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Abstract

included

Constructor Details

#initializeMock

Returns a new instance of Mock.



13
14
15
# File 'lib/mocks/mock.rb', line 13

def initialize
  @mock_calls = []
end

Instance Attribute Details

#mock_callsObject

Returns the value of attribute mock_calls.



11
12
13
# File 'lib/mocks/mock.rb', line 11

def mock_calls
  @mock_calls
end

Instance Method Details

#mock_add(elt) ⇒ Object



33
34
35
# File 'lib/mocks/mock.rb', line 33

def mock_add ( elt )
  @mock_calls << elt unless @mock_calls.frozen?
end

#mock_argsObject



29
30
31
# File 'lib/mocks/mock.rb', line 29

def mock_args
  @mock_calls.map { |call| call.args }
end

#mock_calls_arrayObject



25
26
27
# File 'lib/mocks/mock.rb', line 25

def mock_calls_array
  @mock_calls.map { |call| call.to_a }
end

#mock_clearObject



41
42
43
# File 'lib/mocks/mock.rb', line 41

def mock_clear
  @mock_calls.clear
end

#mock_freezeObject



37
38
39
# File 'lib/mocks/mock.rb', line 37

def mock_freeze
  @mock_calls.freeze
end

#mock_recall(anObject) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/mocks/mock.rb', line 17

def mock_recall ( anObject )
  result = nil
  @mock_calls.each do |call|
    result = call.recall anObject
  end
  result
end

#mock_sizeObject



45
46
47
# File 'lib/mocks/mock.rb', line 45

def mock_size
  @mock_calls.size
end