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

#lengthObject



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

def length
  @expectations.length
end

#match(method_name, *arguments) ⇒ Object



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

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

#match_allowing_invocation(method_name, *arguments) ⇒ Object



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

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)


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

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

#to_aObject



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

def to_a
  @expectations
end

#to_setObject



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

def to_set
  @expectations.to_set
end

#verified?(assertion_counter = nil) ⇒ Boolean

Returns:

  • (Boolean)


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

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