Class: RSpec::Core::Metadata::HashPopulator

Inherits:
Object
  • Object
show all
Defined in:
opal/opal/rspec/fixes/rspec/core/metadata.rb

Instance Method Summary collapse

Instance Method Details

#populate_location_attributesObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'opal/opal/rspec/fixes/rspec/core/metadata.rb', line 21

def populate_location_attributes
  backtrace = .delete(:caller)

  file_path, line_number = if backtrace
                             file_path_and_line_number_from(backtrace)
                             # Opal 0.9 has a stub for this but it does not return anything
                           # elsif block.respond_to?(:source_location)
                           #   block.source_location
                           else
                             file_path_and_line_number_from(caller)
                           end

  file_path = Metadata.relative_path(file_path)
  [:file_path] = file_path
  [:line_number] = line_number.to_i
  [:location] = "#{file_path}:#{line_number}"
end