Class: Mocha::ClassMethods::AnyInstance

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ AnyInstance

Returns a new instance of AnyInstance.



134
135
136
# File 'lib/mocha/object.rb', line 134

def initialize(klass)
  @stubba_object = klass
end

Instance Method Details

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

Returns:

  • (Boolean)


150
151
152
153
154
155
156
157
# File 'lib/mocha/object.rb', line 150

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



138
139
140
# File 'lib/mocha/object.rb', line 138

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

#stubba_methodObject



142
143
144
# File 'lib/mocha/object.rb', line 142

def stubba_method
  Mocha::AnyInstanceMethod
end

#stubba_objectObject



146
147
148
# File 'lib/mocha/object.rb', line 146

def stubba_object
  @stubba_object
end