Class RSpec::Mocks::ConstantMutator
In: lib/rspec/mocks/mutate_const.rb
Parent: Object

Provides a means to stub constants.

Methods

Classes and Modules

Class RSpec::Mocks::ConstantMutator::BaseMutator
Class RSpec::Mocks::ConstantMutator::ConstantHider
Class RSpec::Mocks::ConstantMutator::DefinedConstantReplacer
Class RSpec::Mocks::ConstantMutator::UndefinedConstantSetter

Public Class methods

Ensures the constant stubbing is registered with rspec-mocks space so that stubbed constants can be restored when examples finish.

@api private

Hides a constant.

@param (see ExampleMethods#hide_const)

@see ExampleMethods#hide_const @note It‘s recommended that you use `hide_const` in your

 examples. This is an alternate public API that is provided
 so you can hide constants in other contexts (e.g. helper
 classes).

Uses the mutator to mutate (stub or hide) a constant. Ensures that the mutator is correctly registered so it can be backed out at the end of the test.

@api private

The list of constant mutators that have been used for the current example.

@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).

[Validate]