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

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

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object

Supports lazy evaluation of some values. Extended by ExampleMetadataHash and GroupMetadataHash, which get mixed in to Metadata for ExampleGroups and Examples (respectively).


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rspec/core/metadata.rb', line 36

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, :described_class
    klass = described_class
    store(:described_class, klass)
    # TODO (2011-11-07 DC) deprecate :describes as a key
    store(:describes, klass)
  when :full_description
    store(:full_description, full_description)
  when :description
    store(:description, build_description_from(*self[:description_args]))
  else
    super
  end
end