Sha256: 759dc202f217f5733da23fd1207c13d97e9ae370adcb3fd519ee697cdc52cc12

Contents?: true

Size: 1.14 KB

Versions: 14

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby

#---
# Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
# 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/noop'

class FlexMock
  ####################################################################
  # Match any object
  class AnyMatcher
    def ===(target)
      true
    end
    def inspect
      "ANY"
    end
  end

  ####################################################################
  # Match only things that are equal.
  class EqualMatcher
    def initialize(obj)
      @obj = obj
    end
    def ===(target)
      @obj == target
    end
    def inspect
      "==(#{@obj.inspect})"
    end
  end

  ANY = AnyMatcher.new

  ####################################################################
  # Match only things where the block evaluates to true.
  class ProcMatcher
    def initialize(&block)
      @block = block
    end
    def ===(target)
      @block.call(target)
    end
    def inspect
      "on{...}"
    end
  end
  
  
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
flexmock-0.6.3 lib/flexmock/argument_matchers.rb
flexmock-0.6.4 lib/flexmock/argument_matchers.rb
flexmock-0.7.0 lib/flexmock/argument_matchers.rb
flexmock-0.6.2 lib/flexmock/argument_matchers.rb
flexmock-0.6.0 lib/flexmock/argument_matchers.rb
flexmock-0.6.1 lib/flexmock/argument_matchers.rb
flexmock-0.7.1 lib/flexmock/argument_matchers.rb
flexmock-0.8.1 lib/flexmock/argument_matchers.rb
flexmock-0.8.0 lib/flexmock/argument_matchers.rb
flexmock-0.8.3 lib/flexmock/argument_matchers.rb
flexmock-0.8.2 lib/flexmock/argument_matchers.rb
mack-0.8.2 lib/gems/flexmock-0.8.3/lib/flexmock/argument_matchers.rb
mack-0.8.3.1 lib/gems/flexmock-0.8.3/lib/flexmock/argument_matchers.rb
mack-0.8.3 lib/gems/flexmock-0.8.3/lib/flexmock/argument_matchers.rb