Sha256: 126af226ba9d51142b869220ba5632e034eaae0fdc3ee426fe684b7630174dc4

Contents?: true

Size: 876 Bytes

Versions: 7

Compression:

Stored size: 876 Bytes

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
rr-0.1.5 lib/rr/expectations/argument_equality_expectation.rb
rr-0.1.4 lib/rr/expectations/argument_equality_expectation.rb
rr-0.1.6 lib/rr/expectations/argument_equality_expectation.rb
rr-0.1.3 lib/rr/expectations/argument_equality_expectation.rb
rr-0.1.2 lib/rr/expectations/argument_equality_expectation.rb
rr-0.1.1 lib/rr/expectations/argument_equality_expectation.rb
rr-0.1.7 lib/rr/expectations/argument_equality_expectation.rb