Class: Mocha::ExpectationList

Inherits:
Object
  • Object
show all
Defined in:
lib/mocha/expectation_list.rb

Instance Method Summary collapse

Constructor Details

#initializeExpectationList

Returns a new instance of ExpectationList


5
6
7
# File 'lib/mocha/expectation_list.rb', line 5

def initialize
  @expectations = []
end

Instance Method Details

#add(expectation) ⇒ Object


9
10
11
12
# File 'lib/mocha/expectation_list.rb', line 9

def add(expectation)
  @expectations.unshift(expectation)
  expectation
end

#any?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'lib/mocha/expectation_list.rb', line 46

def any?
  @expectations.any?
end

#lengthObject


42
43
44
# File 'lib/mocha/expectation_list.rb', line 42

def length
  @expectations.length
end

#match(method_name, *arguments) ⇒ Object


22
23
24
# File 'lib/mocha/expectation_list.rb', line 22

def match(method_name, *arguments)
  matching_expectations(method_name, *arguments).first
end

#match_allowing_invocation(method_name, *arguments) ⇒ Object


26
27
28
# File 'lib/mocha/expectation_list.rb', line 26

def match_allowing_invocation(method_name, *arguments)
  matching_expectations(method_name, *arguments).detect { |e| e.invocations_allowed? }
end

#matches_method?(method_name) ⇒ Boolean

Returns:

  • (Boolean)

18
19
20
# File 'lib/mocha/expectation_list.rb', line 18

def matches_method?(method_name)
  @expectations.any? { |expectation| expectation.matches_method?(method_name) }
end

#remove_all_matching_method(method_name) ⇒ Object


14
15
16
# File 'lib/mocha/expectation_list.rb', line 14

def remove_all_matching_method(method_name)
  @expectations.reject! { |expectation| expectation.matches_method?(method_name) }
end

#to_aObject


34
35
36
# File 'lib/mocha/expectation_list.rb', line 34

def to_a
  @expectations
end

#to_setObject


38
39
40
# File 'lib/mocha/expectation_list.rb', line 38

def to_set
  @expectations.to_set
end

#verified?(assertion_counter = nil) ⇒ Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/mocha/expectation_list.rb', line 30

def verified?(assertion_counter = nil)
  @expectations.all? { |expectation| expectation.verified?(assertion_counter) }
end