Class: Mocha::ExpectationList
Instance Method Summary collapse
- #add(expectation) ⇒ Object
-
#initialize ⇒ ExpectationList
constructor
A new instance of ExpectationList.
- #length ⇒ Object
- #match(method_name, *arguments) ⇒ Object
- #match_allowing_invocation(method_name, *arguments) ⇒ Object
- #matches_method?(method_name) ⇒ Boolean
- #to_a ⇒ Object
- #to_set ⇒ Object
- #verified?(assertion_counter = nil) ⇒ Boolean
Constructor Details
#initialize ⇒ ExpectationList
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 |
#length ⇒ Object
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
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_a ⇒ Object
30 31 32 |
# File 'lib/mocha/expectation_list.rb', line 30 def to_a @expectations end |
#to_set ⇒ Object
34 35 36 |
# File 'lib/mocha/expectation_list.rb', line 34 def to_set @expectations.to_set end |
#verified?(assertion_counter = nil) ⇒ 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 |