Sha256: 3ccb4ee016af7436477869e6e8206402a4fd9376bc7d9789df6db33a394c7380

Contents?: true

Size: 891 Bytes

Versions: 5

Compression:

Stored size: 891 Bytes

Contents

module RR
  module Expectations
    class ArgumentEqualityExpectation #:nodoc:
      attr_reader :expected_arguments

      def initialize(*expected_arguments)
        @expected_arguments = expected_arguments
      end

      def exact_match?(*arguments)
        @expected_arguments == arguments
      end

      def wildcard_match?(*arguments)
        return false unless arguments.length == @expected_arguments.length
        arguments.each_with_index do |arg, index|
          expected_argument = @expected_arguments[index]
          if expected_argument.respond_to?(:wildcard_match?)
            return false unless expected_argument.wildcard_match?(arg)
          else
            return false unless expected_argument == arg
          end
        end
        return true
      end

      def ==(other)
        @expected_arguments == other.expected_arguments
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rr-0.4.2 lib/rr/expectations/argument_equality_expectation.rb
rr-0.4.3 lib/rr/expectations/argument_equality_expectation.rb
rr-0.4.1 lib/rr/expectations/argument_equality_expectation.rb
rr-0.4.4 lib/rr/expectations/argument_equality_expectation.rb
rr-0.4.0 lib/rr/expectations/argument_equality_expectation.rb