Sha256: 8d5e99770834cb3901a7d137aa6e29a072c9bff2ea300314e6af8c92db4556db
Contents?: true
Size: 985 Bytes
Versions: 119
Compression:
Stored size: 985 Bytes
Contents
require 'mocha/parameter_matchers/base' 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 < Base # :nodoc: def initialize(klass) @klass = klass end def matches?(available_parameters) parameter = available_parameters.shift parameter.instance_of?(@klass) end def mocha_inspect "instance_of(#{@klass.mocha_inspect})" end end end end
Version data entries
119 entries across 114 versions & 13 rubygems