class RSpec::Mocks::ConstantMutator::ConstantHider

Hides a defined constant for the duration of an example.

@api private

Public Instance Methods

mutate() click to toggle source
# File lib/rspec/mocks/mutate_const.rb, line 224
def mutate
  @context = recursive_const_get(@context_parts.join('::'))
  @original_value = get_const_defined_on(@context, @const_name)

  @context.__send__(:remove_const, @const_name)
end
rspec_reset() click to toggle source
# File lib/rspec/mocks/mutate_const.rb, line 239
def rspec_reset
  @context.const_set(@const_name, @original_value)
end
to_constant() click to toggle source
# File lib/rspec/mocks/mutate_const.rb, line 231
def to_constant
  const = super
  const.hidden = true
  const.previously_defined = true

  const
end