Module: RSpec::Core::Metadata::LocationKeys
- Defined in:
- lib/rspec/core/metadata.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #file_and_line_number ⇒ Object
- #first_caller_from_outside_rspec ⇒ Object
- #location ⇒ Object
Instance Method Details
#[](key) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rspec/core/metadata.rb', line 6 def [](key) return super if has_key?(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) self[key] else super end end |
#file_and_line_number ⇒ Object
25 26 27 28 |
# File 'lib/rspec/core/metadata.rb', line 25 def file_and_line_number first_caller_from_outside_rspec =~ /(.+?):(\d+)(|:\d+)/ return [$1, $2.to_i] end |
#first_caller_from_outside_rspec ⇒ Object
30 31 32 |
# File 'lib/rspec/core/metadata.rb', line 30 def first_caller_from_outside_rspec self[:caller].detect {|l| l !~ /\/lib\/rspec\/core/} end |
#location ⇒ Object
21 22 23 |
# File 'lib/rspec/core/metadata.rb', line 21 def location "#{self[:file_path]}:#{self[:line_number]}" end |