Sha256: c52221b4bbb112ec6a6fff680a1ee99bc23333d70bcc4a770a7f71dced8f1bac

Contents?: true

Size: 873 Bytes

Versions: 45

Compression:

Stored size: 873 Bytes

Contents

module Mocha
  
  module ParameterMatchers

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

Version data entries

45 entries across 45 versions & 3 rubygems

Version Path
redcar-0.5.2dev lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.5.1dev lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.4.1 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.4 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.10.1dev lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.10.0dev lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.9 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.9.0dev lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.8.4 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.8.3 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.8.2 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.8.1 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.8 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.7.1 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.7 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.6 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.5 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.4.3 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.4.2 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb
redcar-0.3.4.1 lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb