123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Core::LegacyExampleGroupHash Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: rspec-core/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 href=":example_group">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  keys that used to be nested
  under {:example_group}.
* Supports mutation (rspec-rails, for example, assigns
  {[:example_group][:described_class]} when you use
  anonymous controller specs) such that changes are written
  back to the top-level  hash.
* Exposes the parent group  as
  {[:example_group][:example_group]}.

Class Method Summary

Instance Method Summary

Instance Method Details

#directly_supports_attribute?(name) ⇒ Boolean (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/metadata.rb', line 485

def directly_supports_attribute?(name)
  name != :example_group
end

#get_value(name) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/metadata.rb', line 489

def get_value(name)
  @metadata[name]
end

#set_value(name, value) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/metadata.rb', line 493

def set_value(name, value)
  @metadata[name] = value
end

#to_h

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/metadata.rb', line 479

def to_h
  super.merge(@metadata)
end