onlyoffice_rspec_result_parser 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e0498075e6fc9529b3ab53e7b99fef574e7e02a8a185e59d7889010402c97a5
4
- data.tar.gz: ad609118fa567af873dcbc09875942b01d306bf91ea80ef4dfe2346e51d3f271
3
+ metadata.gz: fca51873554ec893514f458b6b5efbf163208383283601dee566dffe10b8204e
4
+ data.tar.gz: d3941700b839dd7e52d6d1e6f5614c3d002739189db734fcc8e614ab718ec024
5
5
  SHA512:
6
- metadata.gz: 3060d19a305e4fa19ee1b1c7c9371f141d93f345fcb2dfa9178b3b71f7d3a332a767d70691b6d7a457eed737342f07ccce632d851ceed5af31e6b0630bc44b7a
7
- data.tar.gz: f455696715c4921e44dc463c68e28ca075860fd09a63418da47649a377f096846f4dd7ba65ec92a09910f73c79200a414736e100a8262d86eebcf33dab7148ef
6
+ metadata.gz: 9d3f5b9169f457d29eb9fa2d94a6aea725f41b95eea798d6218faa41fed472095713e4cd739500d31d1337c38b2af90acf9254087d1cacb3b2ecbfadcea832a1
7
+ data.tar.gz: f7f2309be7ae1e2ee1a00721fb00518e7a0c5a3b895a9aec87fd374ee5ac9802a9fa039a867411e59e370d3b348d7cba25c44716dda265f97767a7e97c23f075
@@ -3,11 +3,18 @@
3
3
  module OnlyofficeRspecResultParser
4
4
  # Class for string methods
5
5
  class StringHelper
6
+ # Get style param from string
7
+ # @param [String] string with style
8
+ # @param [String] param name
9
+ # @return [String] result
6
10
  def self.get_style_param(string, param)
7
11
  m = string.match(/#{param}:\s(.*);/)
8
12
  m[1]
9
13
  end
10
14
 
15
+ # Delete pixel names from string
16
+ # @param [String] string to delete
17
+ # @return [String] result
11
18
  def self.delete_px(string)
12
19
  string.gsub 'px', ''
13
20
  end
@@ -11,6 +11,9 @@ module OnlyofficeRspecResultParser
11
11
  @result = result
12
12
  end
13
13
 
14
+ # Find last info on level
15
+ # @param [Integer] level
16
+ # @return [Object] result
14
17
  def find_last_on_lvl(level)
15
18
  level.zero? ? self : @child.last.find_last_on_lvl(level - 1)
16
19
  end
@@ -19,10 +19,11 @@ module OnlyofficeRspecResultParser
19
19
 
20
20
  def fetch_data(data)
21
21
  @text = data.css('span').first.text
22
- @passed = data[:class].split(' ')[1]
23
- if @passed == 'failed'
22
+ @passed = data[:class].split[1]
23
+ case @passed
24
+ when 'failed'
24
25
  fetch_failed_data(data)
25
- elsif @passed == 'passed'
26
+ when 'passed'
26
27
  @duration = data.css('span')[1].text
27
28
  end
28
29
  end
@@ -50,7 +51,7 @@ module OnlyofficeRspecResultParser
50
51
  # @return [String] text with clickable link
51
52
  def format_link(text)
52
53
  links = URI.extract(text)
53
- links.each do |current_link|
54
+ links.uniq.each do |current_link|
54
55
  if current_link.end_with?('png', 'jpg')
55
56
  text.gsub!(current_link, link_url_50_percent(current_link))
56
57
  elsif current_link.start_with?('http')
@@ -6,6 +6,10 @@ module OnlyofficeRspecResultParser
6
6
  # @return [Describe] result describe
7
7
  attr_reader :final_result
8
8
 
9
+ # Push result to end
10
+ # @param [String] describe to pusth
11
+ # @param [Integer] level to check
12
+ # @return [Object] result
9
13
  def push_to_end(describe, level)
10
14
  if level.zero?
11
15
  @final_result = describe
@@ -3,6 +3,7 @@
3
3
  module OnlyofficeRspecResultParser
4
4
  # class for storing rspec result
5
5
  class RspecResult
6
+ # @return [Integer] margin value
6
7
  LEVEL_MARGIN = 15
7
8
 
8
9
  attr_accessor :processing, :result, :time, :total, :describe
@@ -12,31 +13,49 @@ module OnlyofficeRspecResultParser
12
13
  attr_accessor :passed_count
13
14
  # @return [Integer] how much tests pending
14
15
  attr_accessor :pending_count
16
+ # @return [String] html page of RspecResult
17
+ attr_reader :page
18
+
19
+ def initialize(page)
20
+ @page = page
21
+ end
15
22
 
16
23
  # @return [Integer] total test result count
17
24
  def total_tests_count
18
25
  failed_count + passed_count
19
26
  end
20
27
 
21
- def parse_page(page, with_describe_info = true)
22
- @describe = get_describe(page) if with_describe_info
23
- @processing = get_processing(page)
24
- @result = get_total_result(page)
25
- @time = get_total_time(page)
26
- @total = get_totals(page)
27
- @failed_count = get_failed_count(page)
28
- @passed_count = get_passed_count(page)
29
- @pending_count = get_pending_count(page)
28
+ # Parse current page
29
+ # @param [Boolean] with_describe_info should info be parsed
30
+ # @return [RspecResult] result of parse
31
+ def parse_page(with_describe_info: true)
32
+ return self unless valid_html?
33
+
34
+ @describe = fetch_describe if with_describe_info
35
+ @processing = fetch_processing
36
+ @result = fetch_total_result
37
+ @time = fetch_total_time
38
+ @total = fetch_totals
39
+ @failed_count = fetch_failed_count
40
+ @passed_count = fetch_passed_count
41
+ @pending_count = fetch_pending_count
30
42
  self
31
43
  end
32
44
 
45
+ # @return [True, False] is html code is valid
46
+ def valid_html?
47
+ return false unless page.at_css('div.results')
48
+
49
+ true
50
+ end
51
+
33
52
  private
34
53
 
35
- def get_describe(page)
54
+ def fetch_describe
36
55
  results = ResultCreator.new
37
56
  page.at_css('div.results').xpath('./div').each do |current|
38
57
  results.push_to_end(parse_describe(current),
39
- get_describe_level(current))
58
+ fetch_describe_level(current))
40
59
  end
41
60
  results.final_result
42
61
  end
@@ -52,14 +71,14 @@ module OnlyofficeRspecResultParser
52
71
  describe_obj
53
72
  end
54
73
 
55
- def get_describe_level(describe)
74
+ def fetch_describe_level(describe)
56
75
  style_string = describe.xpath('./dl')[0][:style]
57
76
  style_parameter = StringHelper.get_style_param(style_string,
58
77
  'margin-left')
59
78
  StringHelper.delete_px(style_parameter).to_i / LEVEL_MARGIN
60
79
  end
61
80
 
62
- def get_processing(page)
81
+ def fetch_processing
63
82
  processing = page.css('script:contains("moveProgressBar")').last
64
83
  return '0' unless processing
65
84
 
@@ -71,11 +90,11 @@ module OnlyofficeRspecResultParser
71
90
  end
72
91
  end
73
92
 
74
- def get_total_result(page)
75
- get_totals(page).include?(' 0 failures')
93
+ def fetch_total_result
94
+ fetch_totals.include?(' 0 failures')
76
95
  end
77
96
 
78
- def get_totals(page)
97
+ def fetch_totals
79
98
  totals = ''
80
99
  total_elem = page.css('script:contains(" example")')
81
100
  return totals unless total_elem
@@ -88,19 +107,19 @@ module OnlyofficeRspecResultParser
88
107
  end
89
108
  end
90
109
 
91
- def get_failed_count(page)
110
+ def fetch_failed_count
92
111
  page.xpath("//*[@class='example failed']").length
93
112
  end
94
113
 
95
- def get_passed_count(page)
114
+ def fetch_passed_count
96
115
  page.xpath("//*[@class='example passed']").length
97
116
  end
98
117
 
99
- def get_pending_count(page)
118
+ def fetch_pending_count
100
119
  page.xpath("//*[@class='example not_implemented']").length
101
120
  end
102
121
 
103
- def get_total_time(page)
122
+ def fetch_total_time
104
123
  total_time = page.css('script:contains("Finished in")')
105
124
  .text
106
125
  .match(/>(.*?)</)
@@ -17,6 +17,9 @@ module OnlyofficeRspecResultParser
17
17
  class << self
18
18
  attr_accessor :example_index
19
19
 
20
+ # Parse rspec html
21
+ # @param [String] html_path path to file
22
+ # @return [Object] result of parse
20
23
  def parse_rspec_html(html_path)
21
24
  page = Nokogiri::HTML(read_file(html_path))
22
25
  parse_test_result(page)
@@ -31,14 +34,26 @@ module OnlyofficeRspecResultParser
31
34
 
32
35
  alias parse_rspec_html_string parse_rspec_html
33
36
 
37
+ # Get failed count
38
+ # @param [String] html_path path to file
39
+ # @return [Integer] failed count
34
40
  def get_failed_cases_count_from_html(html_path)
35
41
  page = Nokogiri::HTML(read_file(html_path))
36
- RspecResult.new.parse_page(page, true).failed_count
42
+ result = RspecResult.new(page).parse_page
43
+ return 0 unless result.valid_html?
44
+
45
+ result.failed_count
37
46
  end
38
47
 
48
+ # Get total case count
49
+ # @param [String] html_path path to file
50
+ # @return [Integer] total count
39
51
  def get_total_result_of_rspec_html(html_path)
40
52
  page = Nokogiri::HTML(read_file(html_path))
41
- RspecResult.new.parse_page(page, true).total
53
+ result = RspecResult.new(page).parse_page
54
+ return '' unless result.valid_html?
55
+
56
+ result.total
42
57
  end
43
58
 
44
59
  # @param page [String] data in page
@@ -47,7 +62,7 @@ module OnlyofficeRspecResultParser
47
62
  # @return [RspecResult] result of parsing
48
63
  def parse_test_result(page, with_describe_info: true)
49
64
  ResultParser.example_index = 0
50
- RspecResult.new.parse_page(page, with_describe_info)
65
+ RspecResult.new(page).parse_page(with_describe_info: with_describe_info)
51
66
  end
52
67
 
53
68
  private
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Main namespace of gem
3
4
  module OnlyofficeRspecResultParser
4
- VERSION = '0.1.0'
5
+ # @return [String] gem version
6
+ VERSION = '1.0.0'
7
+ # @return [String] gem name
5
8
  NAME = 'onlyoffice_rspec_result_parser'
6
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onlyoffice_rspec_result_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-03-20 00:00:00.000000000 Z
13
+ date: 2022-02-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -26,20 +26,132 @@ dependencies:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.6'
29
+ - !ruby/object:Gem::Dependency
30
+ name: overcommit
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
29
43
  - !ruby/object:Gem::Dependency
30
44
  name: rake
31
45
  requirement: !ruby/object:Gem::Requirement
32
46
  requirements:
33
47
  - - "~>"
34
48
  - !ruby/object:Gem::Version
35
- version: '13.0'
49
+ version: '13'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '13'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rspec
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '3'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '3'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rubocop
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 0.49.0
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 0.49.0
85
+ - !ruby/object:Gem::Dependency
86
+ name: rubocop-performance
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '1'
36
92
  type: :development
37
93
  prerelease: false
38
94
  version_requirements: !ruby/object:Gem::Requirement
39
95
  requirements:
40
96
  - - "~>"
41
97
  - !ruby/object:Gem::Version
42
- version: '13.0'
98
+ version: '1'
99
+ - !ruby/object:Gem::Dependency
100
+ name: rubocop-rake
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rubocop-rspec
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '2'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '2'
127
+ - !ruby/object:Gem::Dependency
128
+ name: simplecov
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - "~>"
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ - !ruby/object:Gem::Dependency
142
+ name: yard
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 0.9.20
148
+ type: :development
149
+ prerelease: false
150
+ version_requirements: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 0.9.20
43
155
  description: Gem to parse rspec results. Needed in wrata project
44
156
  email:
45
157
  - shockwavenn@gmail.com
@@ -55,15 +167,16 @@ files:
55
167
  - lib/onlyoffice_rspec_result_parser/rspec_result_parser/result_creator.rb
56
168
  - lib/onlyoffice_rspec_result_parser/rspec_result_parser/rspec_result.rb
57
169
  - lib/onlyoffice_rspec_result_parser/version.rb
58
- homepage: https://github.com/onlyoffice-testing-robot/onlyoffice_rspec_result_parser
170
+ homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_rspec_result_parser
59
171
  licenses:
60
172
  - AGPL-3.0
61
173
  metadata:
62
- bug_tracker_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_rspec_result_parser/issues
63
- changelog_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_rspec_result_parser/blob/master/CHANGELOG.md
174
+ bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_rspec_result_parser/issues
175
+ changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_rspec_result_parser/blob/master/CHANGELOG.md
64
176
  documentation_uri: https://www.rubydoc.info/gems/onlyoffice_rspec_result_parser
65
- homepage_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_rspec_result_parser
66
- source_code_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_rspec_result_parser
177
+ homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_rspec_result_parser
178
+ source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_rspec_result_parser
179
+ rubygems_mfa_required: 'true'
67
180
  post_install_message:
68
181
  rdoc_options: []
69
182
  require_paths:
@@ -72,14 +185,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
185
  requirements:
73
186
  - - ">="
74
187
  - !ruby/object:Gem::Version
75
- version: '2.3'
188
+ version: '2.5'
76
189
  required_rubygems_version: !ruby/object:Gem::Requirement
77
190
  requirements:
78
191
  - - ">="
79
192
  - !ruby/object:Gem::Version
80
193
  version: '0'
81
194
  requirements: []
82
- rubygems_version: 3.0.6
195
+ rubygems_version: 3.3.7
83
196
  signing_key:
84
197
  specification_version: 4
85
198
  summary: Gem to parse rspec results