Module: OnlyofficeTcmHelper::RspecHelper
- Included in:
- TcmHelper
- Defined in:
- lib/onlyoffice_tcm_helper/helpers/rspec_helper.rb
Overview
module with methods for parsing test results
Class Method Summary collapse
-
.find_dirty_line(example) ⇒ String
Find dirty line in example.
-
.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_dirty_line(example) ⇒ String
Find dirty line in example
24 25 26 27 28 29 30 31 |
# File 'lib/onlyoffice_tcm_helper/helpers/rspec_helper.rb', line 24 def self.find_dirty_line(example) example_path = example.[:absolute_file_path].downcase example.exception.backtrace.find do |line| next unless (line_path = line[/(.+?):(\d+)(|:\d+)/, 1]) File.(line_path).casecmp(example_path).zero? end end |
.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 |
# File 'lib/onlyoffice_tcm_helper/helpers/rspec_helper.rb', line 13 def self.find_failed_line(example) dirty_line = find_dirty_line(example) 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 |