Class: Mocha::ClassMethods::AnyInstance
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(klass) ⇒ AnyInstance
constructor
A new instance of AnyInstance.
- #method_exists?(method, include_public_methods = true) ⇒ Boolean
- #mocha ⇒ Object
- #stubba_method ⇒ Object
- #stubba_object ⇒ Object
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
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 |
#mocha ⇒ Object
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_method ⇒ Object
142 143 144 |
# File 'lib/mocha/object.rb', line 142 def stubba_method Mocha::AnyInstanceMethod end |
#stubba_object ⇒ Object
146 147 148 |
# File 'lib/mocha/object.rb', line 146 def stubba_object @stubba_object end |