Sha256: 3a864e8803fe5300f850646bac26c03474961039760d2c39b4e7b569e24876f5

Contents?: true

Size: 834 Bytes

Versions: 45

Compression:

Stored size: 834 Bytes

Contents

module Mocha
  
  module ParameterMatchers

    # :call-seq: kind_of(klass) -> parameter_matcher
    #
    # Matches any object that is a kind of +klass+
    #   object = mock()
    #   object.expects(:method_1).with(kind_of(Integer))
    #   object.method_1(99)
    #   # no error raised
    #
    #   object = mock()
    #   object.expects(:method_1).with(kind_of(Integer))
    #   object.method_1('string')
    #   # error raised, because method_1 was not called with a kind of Integer
    def kind_of(klass)
      KindOf.new(klass)
    end
    
    class KindOf # :nodoc:
      
      def initialize(klass)
        @klass = klass
      end
    
      def ==(parameter)
        parameter.kind_of?(@klass)
      end
      
      def mocha_inspect
        "kind_of(#{@klass.mocha_inspect})"
      end
      
    end
    
  end
  
end

Version data entries

45 entries across 45 versions & 3 rubygems

Version Path
redcar-dev-0.12.1dev-java lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-dev-0.12.0dev-java lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.11 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.11.0dev lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.10 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.9.2 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.9.1 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.9.0 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.8.1 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.8 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.7 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.6.1 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.6 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.6.1dev lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.5.1 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.5 lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.5.6dev lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.5.5dev lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.5.4dev lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb
redcar-0.5.3dev lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb