Class: OnlyofficeRspecResultParser::ResultParser

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyoffice_rspec_result_parser/rspec_result_parser.rb

Overview

Class with stored data about rspec result

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.example_indexObject

Returns the value of attribute example_index.



18
19
20
# File 'lib/onlyoffice_rspec_result_parser/rspec_result_parser.rb', line 18

def example_index
  @example_index
end

Class Method Details

.get_failed_cases_count_from_html(html_path) ⇒ Integer

Get failed count

Parameters:

  • html_path (String)

    path to file

Returns:

  • (Integer)

    failed count



40
41
42
43
44
45
46
# File 'lib/onlyoffice_rspec_result_parser/rspec_result_parser.rb', line 40

def get_failed_cases_count_from_html(html_path)
  page = Nokogiri::HTML(read_file(html_path))
  result = RspecResult.new(page).parse_page
  return 0 unless result.valid_html?

  result.failed_count
end

.get_total_result_of_rspec_html(html_path) ⇒ Integer

Get total case count

Parameters:

  • html_path (String)

    path to file

Returns:

  • (Integer)

    total count



51
52
53
54
55
56
57
# File 'lib/onlyoffice_rspec_result_parser/rspec_result_parser.rb', line 51

def get_total_result_of_rspec_html(html_path)
  page = Nokogiri::HTML(read_file(html_path))
  result = RspecResult.new(page).parse_page
  return '' unless result.valid_html?

  result.total
end

.parse_metadata(file) ⇒ RspecResult

Returns result of parsing.

Parameters:

  • file (String)

    path to file

Returns:



30
31
32
33
# File 'lib/onlyoffice_rspec_result_parser/rspec_result_parser.rb', line 30

def (file)
  page = Nokogiri::HTML(read_file(file))
  parse_test_result(page, with_describe_info: false)
end

.parse_rspec_html(html_path) ⇒ Object Also known as: parse_rspec_html_string

Parse rspec html

Parameters:

  • html_path (String)

    path to file

Returns:

  • (Object)

    result of parse



23
24
25
26
# File 'lib/onlyoffice_rspec_result_parser/rspec_result_parser.rb', line 23

def parse_rspec_html(html_path)
  page = Nokogiri::HTML(read_file(html_path))
  parse_test_result(page)
end

.parse_test_result(page, with_describe_info: true) ⇒ RspecResult

Returns result of parsing.

Parameters:

  • page (String)

    data in page

  • with_describe_info (Boolean) (defaults to: true)

    if describe metadata should be included

Returns:



63
64
65
66
# File 'lib/onlyoffice_rspec_result_parser/rspec_result_parser.rb', line 63

def parse_test_result(page, with_describe_info: true)
  ResultParser.example_index = 0
  RspecResult.new(page).parse_page(with_describe_info: with_describe_info)
end