Class: RSpec::Mocks::ConstantMutator::ConstantHider Private
- Inherits:
-
BaseMutator
- Object
- BaseMutator
- RSpec::Mocks::ConstantMutator::ConstantHider
- Defined in:
- lib/rspec/mocks/mutate_const.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Hides a defined constant for the duration of an example.
Instance Attribute Summary
Attributes inherited from BaseMutator
#full_constant_name, #original_value
Instance Method Summary (collapse)
- - (Object) mutate private
- - (Object) rspec_reset private
- - (Object) to_constant private
Methods inherited from BaseMutator
Methods included from RecursiveConstMethods
#const_defined_on?, #constants_defined_on, #get_const_defined_on, #normalize_const_name, #recursive_const_defined?, #recursive_const_get
Constructor Details
This class inherits a constructor from RSpec::Mocks::ConstantMutator::BaseMutator
Instance Method Details
- (Object) mutate
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
230 231 232 233 234 235 |
# File 'lib/rspec/mocks/mutate_const.rb', line 230 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 |
- (Object) rspec_reset
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
245 246 247 |
# File 'lib/rspec/mocks/mutate_const.rb', line 245 def rspec_reset @context.const_set(@const_name, @original_value) end |
- (Object) to_constant
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
237 238 239 240 241 242 243 |
# File 'lib/rspec/mocks/mutate_const.rb', line 237 def to_constant const = super const.hidden = true const.previously_defined = true const end |