Class: RSpec::Mocks::ConstantMutator::UndefinedConstantSetter
- Inherits:
-
BaseMutator
- Object
- BaseMutator
- RSpec::Mocks::ConstantMutator::UndefinedConstantSetter
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/mutate_const.rb
Overview
Sets an undefined constant for the duration of an example.
Instance Attribute Summary
Attributes inherited from BaseMutator
#full_constant_name, #original_value
Instance Method Summary collapse
Methods inherited from BaseMutator
#idempotently_reset, #initialize
Methods included from Support::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
#mutate ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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 |
#reset ⇒ Object
299 300 301 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/mutate_const.rb', line 299 def reset @parent.__send__(:remove_const, @const_name) end |
#to_constant ⇒ Object
291 292 293 294 295 296 297 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/mutate_const.rb', line 291 def to_constant const = super const.stubbed = true const.previously_defined = false const end |