Sha256: 3ea98ae018c0627e31d60850de922b56423aa058069b804997cf99efaa4c55c3

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

module Mocha # :nodoc:

  class ExpectationList

    def initialize
      @expectations = []
    end
    
    def add(expectation)
      @expectations.unshift(expectation)
      expectation
    end

    def remove_all_matching_method(method_name)
      @expectations.reject! { |expectation| expectation.matches_method?(method_name) }
    end
    
    def matches_method?(method_name)
      @expectations.any? { |expectation| expectation.matches_method?(method_name) }
    end
    
    def match(method_name, *arguments)
      matching_expectations(method_name, *arguments).first
    end
    
    def match_allowing_invocation(method_name, *arguments)
      matching_expectations(method_name, *arguments).detect { |e| e.invocations_allowed? }
    end
    
    def verified?(assertion_counter = nil)
      @expectations.all? { |expectation| expectation.verified?(assertion_counter) }
    end
    
    def to_a
      @expectations
    end
    
    def to_set
      @expectations.to_set
    end
    
    def length
      @expectations.length
    end
    
    private
    
    def matching_expectations(method_name, *arguments)
      @expectations.select { |e| e.match?(method_name, *arguments) }
    end
    
  end

end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
challah-0.6.1 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.6.0 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.5.4 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.5.3 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.5.2 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.5.0 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.4.1 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.4.0 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.3.5 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.3.4 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.3.3 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.3.2 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.3.1 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.3.0 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.2.1 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
challah-0.2.0 vendor/bundle/gems/mocha-0.10.3/lib/mocha/expectation_list.rb
mocha-0.10.3 lib/mocha/expectation_list.rb
mocha-0.10.2 lib/mocha/expectation_list.rb