module RSpec::Core::Metadata::MetadataHash
@private
Public Instance Methods
[](key)
click to toggle source
@private Supports lazy evaluation of some values. Extended by ExampleMetadataHash and GroupMetadataHash, which get mixed in to Metadata for ExampleGroups and Examples (respectively).
Calls superclass method
# File lib/rspec/core/metadata.rb, line 45 def [](key) store_computed(key) unless has_key?(key) super end
fetch(key, *args)
click to toggle source
Calls superclass method
# File lib/rspec/core/metadata.rb, line 50 def fetch(key, *args) store_computed(key) unless has_key?(key) super end
Private Instance Methods
build_description_from(first_part = '', *parts)
click to toggle source
# File lib/rspec/core/metadata.rb, line 99 def build_description_from(first_part = '', *parts) description, _ = parts.inject([first_part.to_s, first_part]) do |(desc, last_part), this_part| this_part = this_part.to_s this_part = (' ' + this_part) unless method_description_after_module?(last_part, this_part) [(desc + this_part), this_part] end description end
file_and_line_number()
click to toggle source
# File lib/rspec/core/metadata.rb, line 85 def file_and_line_number first_caller_from_outside_rspec =~ /(.+?):(\d+)(|:\d+)/ return [Metadata::relative_path($1), $2.to_i] end
first_caller_from_outside_rspec()
click to toggle source
# File lib/rspec/core/metadata.rb, line 90 def first_caller_from_outside_rspec self[:caller].detect {|l| l !~ /\/lib\/rspec\/core/} end
location()
click to toggle source
# File lib/rspec/core/metadata.rb, line 81 def location "#{self[:file_path]}:#{self[:line_number]}" end
method_description_after_module?(parent_part, child_part)
click to toggle source
# File lib/rspec/core/metadata.rb, line 94 def method_description_after_module?(parent_part, child_part) return false unless parent_part.is_a?(Module) child_part =~ /^(#|::|\.)/ end
store_computed(key)
click to toggle source
# File lib/rspec/core/metadata.rb, line 57 def store_computed(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) 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])) when :description_args store(:description_args, []) end end