Module: OnlyofficeTestrailWrapper::RspecHelper
- Defined in:
- lib/onlyoffice_testrail_wrapper/helpers/rspec_helper.rb
Overview
Methods to some rspec methods
Class Method Summary collapse
-
.find_failed_line(example) ⇒ String
This method is based on github.com/rspec/rspec-core/blob/v3.3.0/lib/rspec/core/formatters/exception_presenter.rb#L130 It extracted exact line of code from failed exception.
Class Method Details
.find_failed_line(example) ⇒ String
This method is based on github.com/rspec/rspec-core/blob/v3.3.0/lib/rspec/core/formatters/exception_presenter.rb#L130 It extracted exact line of code from failed exception
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/onlyoffice_testrail_wrapper/helpers/rspec_helper.rb', line 13 def self.find_failed_line(example) example_path = example.[:absolute_file_path].downcase dirty_line = example.exception.backtrace.find do |line| next unless (line_path = line[/(.+?):(\d+)(|:\d+)/, 1]) File.(line_path).casecmp(example_path).zero? end line_number = dirty_line[/:\d*:/].delete(':').to_i OnlyofficeFileHelper::FileHelper.read_array_from_file(example.[:absolute_file_path])[line_number - 1] rescue StandardError => e "Cannot find failed line because of exception: #{e}" end |