Class: RSpec::Mocks::ConstantMutator::UndefinedConstantSetter Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
BaseMutator
|
|
Instance Chain:
|
|
Inherits: |
RSpec::Mocks::ConstantMutator::BaseMutator
|
Defined in: | rspec-mocks/lib/rspec/mocks/mutate_const.rb |
Overview
Sets an undefined constant for the duration of an example.
Class Method Summary
BaseMutator
- Inherited
Instance Attribute Summary
BaseMutator
- Inherited
Instance Method Summary
- #mutate Internal use only
- #reset Internal use only
- #to_constant Internal use only
- #name_for(parent, name) private Internal use only
BaseMutator
- Inherited
::RSpec::Support::RecursiveConstMethods
- Included
#const_defined_on? | See additional method definition at line 31. |
#constants_defined_on | See additional method definition at line 41. |
#get_const_defined_on | See additional method definition at line 35. |
#normalize_const_name, #recursive_const_defined?, #recursive_const_get |
Instance Method Details
#mutate
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 279
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
#name_for(parent, name) (private)
[ GitHub ]#reset
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 299
def reset @parent.__send__(:remove_const, @const_name) end
#to_constant
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 291
def to_constant const = super const.stubbed = true const.previously_defined = false const end