Sha256: a96546fd667098c65a7f389cba411f8ba7107c8535c9430049d355cba9d76289

Contents?: true

Size: 1.41 KB

Versions: 23

Compression:

Stored size: 1.41 KB

Contents

#!/usr/bin/env ruby

#---
# Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
# All rights reserved.

# Permission is granted for use, copying, modification, distribution,
# and distribution of modified versions of this work as long as the
# above copyright notice is included.
#+++

require 'flexmock/argument_matchers'

class FlexMock

  # Include this module in your test class if you wish to use the +eq+
  # and +any+ argument matching methods without a prefix.  (Otherwise
  # use <tt>FlexMock.any</tt> and <tt>FlexMock.eq(obj)</tt>.
  #
  module ArgumentTypes
    # Return an argument matcher that matches any argument.
    def any
      ANY
    end

    # Return an argument matcher that only matches things equal to
    # (==) the given object.
    def eq(obj)
      EqualMatcher.new(obj)
    end

    # Return an argument matcher that matches any object, that when
    # passed to the supplied block, will cause the block to return
    # true.
    def on(&block)
      ProcMatcher.new(&block)
    end

    # Return an argument matcher that matches a hash with the given
    # entries.
    def hsh(hash)
      HashMatcher.new(hash)
    end

    # Return an argument matcher that matches any object that
    # implementes (i.e. responds to) the given method list.
    def ducktype(*methods)
      DuckMatcher.new(methods)
    end

    def optional_proc
      OPTIONAL_PROC_MATCHER
    end
  end
  extend ArgumentTypes

end

Version data entries

23 entries across 23 versions & 1 rubygems

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