Module: RSpec::Core::Metadata::MetadataHash

Included in:
GroupMetadataHash
Defined in:
lib/rspec/core/metadata.rb

Overview

Used to extend metadata Hashes to support lazy evaluation of locations and descriptions.

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rspec/core/metadata.rb', line 8

def [](key)
  return super if has_key?(key)
  case key
  when :location
    store(:location, location)
  when :file_path, :line_number
    file_path, line_number = file_and_line_number
    store(:file_path, file_path)
    store(:line_number, line_number)
    super
  when :execution_result
    store(:execution_result, {})
  when :describes
    store(:describes, described_class_for(self))
  when :full_description
    store(:full_description, full_description_for(self))
  when :description
    store(:description, build_description_from(*self[:description_args]))
  else
    super
  end
end