Class: RSpec::Core::LegacyExampleGroupHash
- Includes:
- HashImitatable
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/metadata.rb
Overview
Together with the example group metadata hash default block, provides backwards compatibility for the old ‘:example_group` key. In RSpec 2.x, the computed keys of a group’s metadata were exposed from a nested subhash keyed by ‘[:example_group]`, and then the parent group’s metadata was exposed by sub-subhash keyed by ‘[:example_group]`.
In RSpec 3, we reorganized this to that the computed keys are exposed directly of the group metadata hash (no nesting), and ‘:parent_example_group` returns the parent group’s metadata.
Maintaining backwards compatibility was difficult: we wanted ‘:example_group` to return an object that:
* Exposes the top-level metadata keys that used to be nested
under `:example_group`.
* Supports mutation (rspec-rails, for example, assigns
`metadata[:example_group][:described_class]` when you use
anonymous controller specs) such that changes are written
back to the top-level metadata hash.
* Exposes the parent group metadata as
`[:example_group][:example_group]`.
Instance Method Summary collapse
-
#initialize(metadata) ⇒ LegacyExampleGroupHash
constructor
A new instance of LegacyExampleGroupHash.
- #to_h ⇒ Object
Methods included from HashImitatable
Constructor Details
#initialize(metadata) ⇒ LegacyExampleGroupHash
Returns a new instance of LegacyExampleGroupHash.
473 474 475 476 477 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/metadata.rb', line 473 def initialize() @metadata = = .fetch(:parent_example_group) { {} }[:example_group] self[:example_group] = if end |
Instance Method Details
#to_h ⇒ Object
479 480 481 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/metadata.rb', line 479 def to_h super.merge(@metadata) end |