Class: Mocha::ClassMethods::AnyInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/mocha/object.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ AnyInstance


195
196
197
# File 'lib/mocha/object.rb', line 195

def initialize(klass)
  @stubba_object = klass
end

Instance Method Details

#method_exists?(method, include_public_methods = true) ⇒ Boolean


211
212
213
214
215
216
217
218
# File 'lib/mocha/object.rb', line 211

def method_exists?(method, include_public_methods = true)
  if include_public_methods
    return true if @stubba_object.public_instance_methods(include_superclass_methods = true).include?(method)
  end
  return true if @stubba_object.protected_instance_methods(include_superclass_methods = true).include?(method)
  return true if @stubba_object.private_instance_methods(include_superclass_methods = true).include?(method)
  return false
end

#mochaObject


199
200
201
# File 'lib/mocha/object.rb', line 199

def mocha
  @mocha ||= Mocha::Mockery.instance.mock_impersonating_any_instance_of(@stubba_object)
end

#stubba_methodObject


203
204
205
# File 'lib/mocha/object.rb', line 203

def stubba_method
  Mocha::AnyInstanceMethod
end

#stubba_objectObject


207
208
209
# File 'lib/mocha/object.rb', line 207

def stubba_object
  @stubba_object
end