class Mocha::ExpectationList
Public Class Methods
new()
click to toggle source
# File lib/mocha/expectation_list.rb, line 5 def initialize @expectations = [] end
Public Instance Methods
add(expectation)
click to toggle source
# File lib/mocha/expectation_list.rb, line 9 def add(expectation) @expectations.unshift(expectation) expectation end
any?()
click to toggle source
# File lib/mocha/expectation_list.rb, line 46 def any? @expectations.any? end
length()
click to toggle source
# File lib/mocha/expectation_list.rb, line 42 def length @expectations.length end
match(method_name, *arguments)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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_a()
click to toggle source
# File lib/mocha/expectation_list.rb, line 34 def to_a @expectations end
to_set()
click to toggle source
# File lib/mocha/expectation_list.rb, line 38 def to_set @expectations.to_set end
verified?(assertion_counter = nil)
click to toggle source
# File lib/mocha/expectation_list.rb, line 30 def verified?(assertion_counter = nil) @expectations.all? { |expectation| expectation.verified?(assertion_counter) } end
Private Instance Methods
matching_expectations(method_name, *arguments)
click to toggle source
# File lib/mocha/expectation_list.rb, line 52 def matching_expectations(method_name, *arguments) @expectations.select { |e| e.match?(method_name, *arguments) } end