Sha256: 625a052376e798b020e82b72a5db189a28efa574f6796dc0b8b0a70867dd2a42

Contents?: true

Size: 1.22 KB

Versions: 40

Compression:

Stored size: 1.22 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

40 entries across 36 versions & 8 rubygems

Version Path
jferris-rr-0.7.1.0.1239654108 lib/rr/expectations/argument_equality_expectation.rb
redinger-redinger-rr-0.10.3 lib/rr/expectations/argument_equality_expectation.rb
redinger-rr-0.10.4 lib/rr/expectations/argument_equality_expectation.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/expectations/argument_equality_expectation.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/expectations/argument_equality_expectation.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/expectations/argument_equality_expectation.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/expectations/argument_equality_expectation.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/expectations/argument_equality_expectation.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/expectations/argument_equality_expectation.rb
bitclust-core-0.5.1 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/expectations/argument_equality_expectation.rb
mcmire-rr-1.0.5.rc1 lib/rr/expectations/argument_equality_expectation.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rr-1.0.2/lib/rr/expectations/argument_equality_expectation.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rr-1.0.2/lib/rr/expectations/argument_equality_expectation.rb
rr-1.0.4 lib/rr/expectations/argument_equality_expectation.rb
rr-1.0.3 lib/rr/expectations/argument_equality_expectation.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/expectations/argument_equality_expectation.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/expectations/argument_equality_expectation.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/expectations/argument_equality_expectation.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/expectations/argument_equality_expectation.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/expectations/argument_equality_expectation.rb