Sha256: 6a03ee75128aa6e61e9f32760f9fe8374e9187e8d2ab0e492b154ba81d405b5a

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

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)
        return false unless arguments.length == @expected_arguments.length
        arguments.each_with_index do |arg, index|
          return false unless equality_match(@expected_arguments[index], arg)
        end
        true
      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 equality_match(expected_argument, arg)
          end
        end
        true
      end

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

      protected
      def equality_match(arg1, arg2)
        arg1.respond_to?(:'__rr__original_==') ? arg1.__send__(:'__rr__original_==', arg2) : arg1 == arg2
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
adva-0.3.2 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.3.1 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.3.0 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.2.4 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.2.3 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.2.2 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.2.1 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.2.0 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.1.4 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.1.3 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.1.2 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.1.1 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.1.0 test/rr/lib/rr/expectations/argument_equality_expectation.rb
adva-0.0.1 test/rr/lib/rr/expectations/argument_equality_expectation.rb
rr-0.6.0 lib/rr/expectations/argument_equality_expectation.rb
rr-0.7.0 lib/rr/expectations/argument_equality_expectation.rb