class RSpec::Mocks::ConstantMutator::UndefinedConstantSetter
@private
Sets an undefined constant for the duration of an example.
def mutate
def mutate @parent = @context_parts.inject(Object) do |klass, name| if const_defined_on?(klass, name) get_const_defined_on(klass, name) else ConstantMutator.stub(name_for(klass, name), Module.new) end end @parent.const_set(@const_name, @mutated_value) end
def name_for(parent, name)
def name_for(parent, name) root = if parent == Object '' else parent.name end root + '::' + name end
def reset
def reset @parent.__send__(:remove_const, @const_name) end
def to_constant
def to_constant const = super const.stubbed = true const.previously_defined = false const end