module RSpec::Core::Metadata
def self.ascend(metadata)
- Private: -
def self.ascend(metadata) enum_for(:ascending, metadata) end
def self.ascending(metadata)
- Private: -
def self.ascending(metadata) yield metadata return unless (group_metadata = metadata.fetch(:example_group) { metadata[:parent_example_group] }) loop do yield group_metadata break unless (group_metadata = group_metadata[:parent_example_group]) end end
def self.backtrace_from(block)
- Private: -
def self.backtrace_from(block) return caller unless block.respond_to?(:source_location) [block.source_location.join(':')] end
def self.build_hash_from(args, warn_about_example_group_filtering=false)
- Private: -
def self.build_hash_from(args, warn_about_example_group_filtering=false) hash = args.last.is_a?(Hash) ? args.pop : {} hash[args.pop] = true while args.last.is_a?(Symbol) if warn_about_example_group_filtering && hash.key?(:example_group) RSpec.deprecate("Filtering by an `:example_group` subhash", :replacement => "the subhash to filter directly") end hash end
def self.deep_hash_dup(object)
- Private: -
def self.deep_hash_dup(object) return object.dup if Array === object return object unless Hash === object object.inject(object.dup) do |duplicate, (key, value)| duplicate[key] = deep_hash_dup(value) duplicate end end
def self.relative_path(line)
-
(String)
- relative path to line
Parameters:
-
line
(String
) -- current code line
Other tags:
- Api: - private
def self.relative_path(line) line = line.sub(relative_path_regex, "\\1.\\2".freeze) line = line.sub(/\A([^:]+:\d+)$/, '\\1'.freeze) return nil if line == '-e:1'.freeze line rescue SecurityError nil end
def self.relative_path_regex
http://rubular.com/r/duOrD4i3wb
http://rubular.com/r/fT0gmX6VJX
before and the character after the string if any.
separator, or at the end of the string. Match groups are the character
whitespace, containing the current path, either postfixed with the
Matches strings either at the beginning of the input or prefixed with a
def self.relative_path_regex @relative_path_regex ||= /(\A|\s)#{File.expand_path('.')}(#{File::SEPARATOR}|\s|\Z)/ end