Module: RSpec::Core::Metadata
- Defined in:
- lib/rspec/core/metadata.rb
Overview
Each ExampleGroup class and Example instance owns an instance of Metadata, which is Hash extended to support lazy evaluation of values associated with keys that may or may not be used by any example or group.
In addition to metadata that is used internally, this also stores user-supplied metadata, e.g.
describe Something, :type => :ui do
it "does something", :slow => true do
# ...
end
end
:type => :ui
is stored in the Metadata owned by the example group, and
:slow => true
is stored in the Metadata owned by the example. These can
then be used to select which examples are run using the --tag
option on
the command line, or several methods on Configuration
used to filter a
run (e.g. filter_run_including
, filter_run_excluding
, etc).
Constant Summary
Class Method Summary (collapse)
-
+ (String) relative_path(line)
private
Relative path to line.
Class Method Details
+ (String) relative_path(line)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns relative path to line
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rspec/core/metadata.rb', line 32 def self.relative_path(line) # Matches strings either at the beginning of the input or prefixed with a whitespace, # containing the current path, either postfixed with the separator, or at the end of the string. # Match groups are the character before and the character after the string if any. # # http://rubular.com/r/fT0gmX6VJX # http://rubular.com/r/duOrD4i3wb # http://rubular.com/r/sbAMHFrOx1 # regex = /(\A|\s)#{File.('.')}(#{File::SEPARATOR}|\s|\Z)/ line = line.sub(regex, "\\1.\\2") line = line.sub(/\A([^:]+:\d+)$/, '\\1') return nil if line == '-e:1' line rescue SecurityError nil end |