Class | RSpec::Mocks::ConstantStubber |
In: |
lib/rspec/mocks/stub_const.rb
|
Parent: | Object |
Provides a means to stub constants.
Ensures the constant stubbing is registered with rspec-mocks space so that stubbed constants can be restored when examples finish.
@api private
Used internally by the constant stubbing to raise a helpful error when a constant like "A::B::C" is stubbed and A::B is not a module (and thus, it‘s impossible to define "A::B::C" since only modules can have nested constants).
@api private
Resets all stubbed constants. This is called automatically by rspec-mocks when an example finishes.
@api private
Stubs a constant.
@param (see ExampleMethods#stub_const) @option (see ExampleMethods#stub_const) @return (see ExampleMethods#stub_const)
@see ExampleMethods#stub_const @note It‘s recommended that you use `stub_const` in your
examples. This is an alternate public API that is provided so you can stub constants in other contexts (e.g. helper classes).