module RSpec::Core::Metadata
Experimental RBS support (using type sampling data from the type_fusion project).
# sig/rspec/core/metadata.rbs module RSpec::Core::Metadata def self.build_hash_from: (Array[] args, ?false warn_about_example_group_filtering) -> untyped def self.id_from: (Hash metadata) -> String def self.relative_path: (String line) -> String end
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.build_hash_from(args, warn_about_example_group_filtering=false)
Experimental RBS support (using type sampling data from the type_fusion project).
def self.build_hash_from: ( args, ?false warn_about_example_group_filtering) -> untyped
This signature was generated using 1 sample from 1 application.
- 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.id_from(metadata)
Experimental RBS support (using type sampling data from the type_fusion project).
def self.id_from: (block | Proc | description_args | | description | String | full_description | String | described_class | NilClass | file_path | String | line_number | Integer | location | String | absolute_file_path | String | rerun_file_path | String | scoped_id | String | order | Symbol | execution_result | RSpec::Core::Example::ExecutionResult | example_group | block | Proc | description_args | | description | String | full_description | String | described_class | NilClass | file_path | String | line_number | Integer | location | String | absolute_file_path | String | rerun_file_path | String | scoped_id | String | order | Symbol | parent_example_group | block | Proc | description_args | | description | String | full_description | String | described_class | NilClass | file_path | String | line_number | Integer | location | String | absolute_file_path | String | rerun_file_path | String | scoped_id | String | order | Symbol | shared_group_inclusion_backtrace | metadata) -> String
This signature was generated using 1 sample from 1 application.
- Private: -
def self.id_from(metadata) "#{metadata[:rerun_file_path]}[#{metadata[:scoped_id]}]" end
def self.location_tuple_from(metadata)
- Private: -
def self.location_tuple_from(metadata) [metadata[:absolute_file_path], metadata[:line_number]] end
def self.relative_path(line)
Experimental RBS support (using type sampling data from the type_fusion project).
def self.relative_path: (String line) -> String
This signature was generated using 3 samples from 1 application.
-
(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 # :nocov: nil # :nocov: 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