Method: RSpec::Mocks::ExampleMethods#hide_const

Defined in:
lib/rspec/mocks/example_methods.rb

#hide_const(constant_name) ⇒ Object

Hides the named constant with the given value. The constant will be undefined for the duration of the test.

Like method stubs, the constant will be restored to its original value when the example completes.

Examples:

hide_const("MyClass") # => MyClass is now an undefined constant

Parameters:

  • constant_name (String)

    The fully qualified name of the constant. The current constant scoping at the point of call is not considered.



256
257
258
# File 'lib/rspec/mocks/example_methods.rb', line 256

def hide_const(constant_name)
  ConstantMutator.hide(constant_name)
end