class Mocha::ExpectationList

Public Class Methods

new(expectations = []) click to toggle source
# File lib/mocha/expectation_list.rb, line 3
def initialize(expectations = [])
  @expectations = expectations
end

Public Instance Methods

+(other) click to toggle source
# File lib/mocha/expectation_list.rb, line 48
def +(other)
  self.class.new(to_a + other.to_a)
end
add(expectation) click to toggle source
# File lib/mocha/expectation_list.rb, line 7
def add(expectation)
  @expectations.unshift(expectation)
  expectation
end
any?() click to toggle source
# File lib/mocha/expectation_list.rb, line 44
def any?
  @expectations.any?
end
length() click to toggle source
# File lib/mocha/expectation_list.rb, line 40
def length
  @expectations.length
end
match(invocation) click to toggle source
# File lib/mocha/expectation_list.rb, line 20
def match(invocation)
  matching_expectations(invocation).first
end
match_allowing_invocation(invocation) click to toggle source
# File lib/mocha/expectation_list.rb, line 24
def match_allowing_invocation(invocation)
  matching_expectations(invocation).detect(&:invocations_allowed?)
end
matches_method?(method_name) click to toggle source
# File lib/mocha/expectation_list.rb, line 16
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 12
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 32
def to_a
  @expectations
end
to_set() click to toggle source
# File lib/mocha/expectation_list.rb, line 36
def to_set
  @expectations.to_set
end
verified?(assertion_counter = nil) click to toggle source
# File lib/mocha/expectation_list.rb, line 28
def verified?(assertion_counter = nil)
  @expectations.all? { |expectation| expectation.verified?(assertion_counter) }
end

Private Instance Methods

matching_expectations(invocation) click to toggle source
# File lib/mocha/expectation_list.rb, line 54
def matching_expectations(invocation)
  @expectations.select { |e| e.match?(invocation) }
end