Sha256: 9520cf90e7fcf1f5119bd213000a9a2e47a36815ecfc6ac32582ea2cd01ed0c6

Contents?: true

Size: 882 Bytes

Versions: 25

Compression:

Stored size: 882 Bytes

Contents

module RR
  module Expectations
    class ArgumentEqualityExpectation
      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

25 entries across 25 versions & 1 rubygems

Version Path
rr-0.3.8 lib/rr/expectations/argument_equality_expectation.rb
rr-0.3.7 lib/rr/expectations/argument_equality_expectation.rb
rr-0.3.9 lib/rr/expectations/argument_equality_expectation.rb
rr-0.3.6 lib/rr/expectations/argument_equality_expectation.rb
rr-0.3.5 lib/rr/expectations/argument_equality_expectation.rb