Sha256: 89387116ac3e978816f43109d6dfe37e5c9cc1d70f9209755eac8081ff44c0c6

Contents?: true

Size: 817 Bytes

Versions: 37

Compression:

Stored size: 817 Bytes

Contents

class FlexMock
  module ArgumentMatching
    module_function

    MISSING_ARG = Object.new

    def all_match?(expected_args, actual_args)
      return true if expected_args.nil?
      return false if actual_args.size > expected_args.size
      i = 0
      while i < actual_args.size
        return false unless match?(expected_args[i], actual_args[i])
        i += 1
      end
      while i < expected_args.size
        return false unless match?(expected_args[i], MISSING_ARG)
        i += 1
      end
      true
    end

    # Does the expected argument match the corresponding actual value.
    def match?(expected, actual)
      expected === actual ||
      expected == actual ||
      ( Regexp === expected && expected === actual.to_s )
    end

    def missing?(arg)
      arg == MISSING_ARG
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
flexmock-2.4.2 lib/flexmock/argument_matching.rb
flexmock-2.4.1 lib/flexmock/argument_matching.rb
flexmock-2.4.0 lib/flexmock/argument_matching.rb
flexmock-2.3.8 lib/flexmock/argument_matching.rb
flexmock-2.3.6 lib/flexmock/argument_matching.rb
flexmock-2.3.5 lib/flexmock/argument_matching.rb
flexmock-2.3.4 lib/flexmock/argument_matching.rb
flexmock-2.3.3 lib/flexmock/argument_matching.rb
flexmock-2.3.2 lib/flexmock/argument_matching.rb
flexmock-2.3.1 lib/flexmock/argument_matching.rb
flexmock-2.3.0 lib/flexmock/argument_matching.rb
flexmock-2.2.1 lib/flexmock/argument_matching.rb
flexmock-2.2.0 lib/flexmock/argument_matching.rb
flexmock-2.1.0 lib/flexmock/argument_matching.rb
flexmock-2.0.6 lib/flexmock/argument_matching.rb
flexmock-2.0.5 lib/flexmock/argument_matching.rb
flexmock-2.0.4 lib/flexmock/argument_matching.rb
flexmock-2.0.3 lib/flexmock/argument_matching.rb
flexmock-2.0.2 lib/flexmock/argument_matching.rb
flexmock-2.0.1 lib/flexmock/argument_matching.rb