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

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

Instance Method Details

#container_stackObject



145
146
147
148
149
150
151
152
153
154
# File 'lib/rspec/core/metadata.rb', line 145

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



127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/rspec/core/metadata.rb', line 127

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

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

  nil
end

#full_descriptionObject



141
142
143
# File 'lib/rspec/core/metadata.rb', line 141

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