class RSpec::Mocks::ConstantMutator::UndefinedConstantSetter
@api private
Sets an undefined constant for the duration of an example.
def mutate
def mutate remaining_parts = @context_parts.dup @deepest_defined_const = @context_parts.inject(Object) do |klass, name| break klass unless const_defined_on?(klass, name) remaining_parts.shift get_const_defined_on(klass, name) end context = remaining_parts.inject(@deepest_defined_const) do |klass, name| klass.const_set(name, Module.new) end @const_to_remove = remaining_parts.first || @const_name context.const_set(@const_name, @mutated_value) end
def rspec_reset
def rspec_reset @deepest_defined_const.__send__(:remove_const, @const_to_remove) end
def to_constant
def to_constant const = super const.stubbed = true const.previously_defined = false const end