Module: RSpec::Mocks
- Defined in:
- lib/rspec/mocks.rb,
lib/rspec/mocks/mock.rb,
lib/rspec/mocks/proxy.rb,
lib/rspec/mocks/space.rb,
lib/rspec/mocks/errors.rb,
lib/rspec/mocks/version.rb,
lib/rspec/mocks/methods.rb,
lib/rspec/mocks/order_group.rb,
lib/rspec/mocks/test_double.rb,
lib/rspec/mocks/mutate_const.rb,
lib/rspec/mocks/any_instance.rb,
lib/rspec/mocks/method_double.rb,
lib/rspec/mocks/serialization.rb,
lib/rspec/mocks/configuration.rb,
lib/rspec/mocks/example_methods.rb,
lib/rspec/mocks/error_generator.rb,
lib/rspec/mocks/argument_matchers.rb,
lib/rspec/mocks/any_instance/chain.rb,
lib/rspec/mocks/message_expectation.rb,
lib/rspec/mocks/any_instance/recorder.rb,
lib/rspec/mocks/argument_list_matcher.rb,
lib/rspec/mocks/any_instance/stub_chain.rb,
lib/rspec/mocks/instance_method_stasher.rb,
lib/rspec/mocks/extensions/instance_exec.rb,
lib/rspec/mocks/any_instance/message_chains.rb,
lib/rspec/mocks/any_instance/stub_chain_chain.rb,
lib/rspec/mocks/any_instance/expectation_chain.rb
Defined Under Namespace
Modules: AnyInstance, ArgumentMatchers, ExampleMethods, Methods, RecursiveConstMethods, TestDouble, Version Classes: ArgumentListMatcher, Configuration, Constant, ConstantMutator, MessageExpectation, Mock, Space
Constant Summary
- KERNEL_METHOD_METHOD =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
::Kernel.instance_method(:method)
- ConstantStubber =
Keeps backwards compatibility since we had released an rspec-mocks that only supported stubbing. Later, we released the hide_const feature and decided that the term "mutator" was a better term to wrap up the concept of both stubbing and hiding.
ConstantMutator
Class Attribute Summary (collapse)
-
+ (Object) space
Returns the value of attribute space.
Class Method Summary (collapse)
- + (Object) configuration
-
+ (Object) method_handle_for(object, method_name)
private
Used internally to get a method handle for a particular object and method name.
- + (Object) setup(host)
- + (Object) teardown
- + (Object) verify
-
+ (Object) warn_deprecation(message)
private
Used internally by RSpec to display custom deprecation warnings.
Class Attribute Details
+ (Object) space
Returns the value of attribute space
8 9 10 |
# File 'lib/rspec/mocks.rb', line 8 def space @space end |
Class Method Details
+ (Object) configuration
26 27 28 |
# File 'lib/rspec/mocks.rb', line 26 def configuration @configuration ||= Configuration.new end |
+ (Object) method_handle_for(object, method_name)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used internally to get a method handle for a particular object and method name.
Includes handling for a few special cases:
- Objects that redefine #method (e.g. an HTTPRequest struct)
- BasicObject subclasses that mixin a Kernel dup (e.g. SimpleDelegator)
49 50 51 52 53 54 55 |
# File 'lib/rspec/mocks.rb', line 49 def method_handle_for(object, method_name) if ::Kernel === object KERNEL_METHOD_METHOD.bind(object).call(method_name) else object.method(method_name) end end |
+ (Object) setup(host)
10 11 12 13 14 15 16 |
# File 'lib/rspec/mocks.rb', line 10 def setup(host) add_extensions unless extensions_added? (class << host; self; end).class_eval do include RSpec::Mocks::ExampleMethods end self.space ||= RSpec::Mocks::Space.new end |
+ (Object) teardown
22 23 24 |
# File 'lib/rspec/mocks.rb', line 22 def teardown space.reset_all end |
+ (Object) verify
18 19 20 |
# File 'lib/rspec/mocks.rb', line 18 def verify space.verify_all end |
+ (Object) warn_deprecation(message)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used internally by RSpec to display custom deprecation warnings. This is also defined in rspec-core, but we can't assume it's loaded since rspec-expectations should be usable w/o rspec-core.
34 35 36 |
# File 'lib/rspec/mocks.rb', line 34 def warn_deprecation() warn() end |