Module: RSpec::Core::Metadata::GroupMetadataHash

Includes:
MetadataHash
Defined in:
lib/rspec/core/metadata.rb

Overview

Mixed in to Metadata for an ExampleGroup (extends MetadataHash) to support lazy evaluation of some values.

Instance Method Summary collapse

Methods included from MetadataHash

#[]

Instance Method Details

#container_stackObject



121
122
123
124
125
126
127
128
129
130
# File 'lib/rspec/core/metadata.rb', line 121

def container_stack
  @container_stack ||= begin
                         groups = [group = self]
                         while group.has_key?(:example_group)
                           groups << group[:example_group]
                           group = group[:example_group]
                         end
                         groups
                       end
end

#described_classObject



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/rspec/core/metadata.rb', line 103

def described_class
  container_stack.each do |g|
    return g[:describes]       if g.has_key?(:describes)
    return g[:described_class] if g.has_key?(:described_class)
  end

  container_stack.reverse.each do |g|
    candidate = g[:description_args].first
    return candidate unless String === candidate || Symbol === candidate
  end

  nil
end

#full_descriptionObject



117
118
119
# File 'lib/rspec/core/metadata.rb', line 117

def full_description
  build_description_from(*container_stack.reverse.map {|a| a[:description_args]}.flatten)
end