module RSpec::Core::Metadata::MetadataHash
def [](key)
- Private: -
def [](key) store_computed(key) unless has_key?(key) super end
def build_description_from(first_part = '', *parts)
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
def fetch(key, *args)
def fetch(key, *args) store_computed(key) unless has_key?(key) super end
def file_and_line_number
def file_and_line_number first_caller_from_outside_rspec =~ /(.+?):(\d+)(|:\d+)/ return [Metadata::relative_path($1), $2.to_i] end
def first_caller_from_outside_rspec
def first_caller_from_outside_rspec self[:caller].detect {|l| l !~ /\/lib\/rspec\/core/} end
def location
def location "#{self[:file_path]}:#{self[:line_number]}" end
def method_description_after_module?(parent_part, child_part)
def method_description_after_module?(parent_part, child_part) return false unless parent_part.is_a?(Module) child_part =~ /^(#|::|\.)/ end
def store_computed(key)
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