onlyoffice_rspec_result_parser 0.1.1 → 0.1.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de345de09e6bcbeb4b5a175a6e06d22986684da50e75ea860e700c9c3d161675
|
4
|
+
data.tar.gz: 7bba8b2ba22b9a9c94a8faa2f475353037b8f8bf0602c9bcccad19c416614ccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2175fc3e4324f977c83b39ad2142f765bfe1b4bd9248587f719e75de9cf638087a0f230fcb9841493abdbd98495b6c49dbb3c033a45ea6cccfb577b1514c5aa1
|
7
|
+
data.tar.gz: 3c862db57ea7ed237a9a8c662be49a15d81563e78921a5dd402ff484ca94ecfb37e8da211c38b8dd2768a6771262a160b87d46a81dd4608e9c9e45bf76c9dcd4
|
@@ -32,17 +32,19 @@ module OnlyofficeRspecResultParser
|
|
32
32
|
alias parse_rspec_html_string parse_rspec_html
|
33
33
|
|
34
34
|
def get_failed_cases_count_from_html(html_path)
|
35
|
-
return 0 if html_path.empty?
|
36
|
-
|
37
35
|
page = Nokogiri::HTML(read_file(html_path))
|
38
|
-
RspecResult.new.parse_page(
|
36
|
+
result = RspecResult.new(page).parse_page(true)
|
37
|
+
return 0 unless result.valid_html?
|
38
|
+
|
39
|
+
result.failed_count
|
39
40
|
end
|
40
41
|
|
41
42
|
def get_total_result_of_rspec_html(html_path)
|
42
|
-
return html_path if html_path.empty?
|
43
|
-
|
44
43
|
page = Nokogiri::HTML(read_file(html_path))
|
45
|
-
RspecResult.new.parse_page(
|
44
|
+
result = RspecResult.new(page).parse_page(true)
|
45
|
+
return '' unless result.valid_html?
|
46
|
+
|
47
|
+
result.total
|
46
48
|
end
|
47
49
|
|
48
50
|
# @param page [String] data in page
|
@@ -51,7 +53,7 @@ module OnlyofficeRspecResultParser
|
|
51
53
|
# @return [RspecResult] result of parsing
|
52
54
|
def parse_test_result(page, with_describe_info: true)
|
53
55
|
ResultParser.example_index = 0
|
54
|
-
RspecResult.new.parse_page(
|
56
|
+
RspecResult.new(page).parse_page(with_describe_info)
|
55
57
|
end
|
56
58
|
|
57
59
|
private
|
@@ -12,31 +12,46 @@ module OnlyofficeRspecResultParser
|
|
12
12
|
attr_accessor :passed_count
|
13
13
|
# @return [Integer] how much tests pending
|
14
14
|
attr_accessor :pending_count
|
15
|
+
# @return [String] html page of RspecResult
|
16
|
+
attr_reader :page
|
17
|
+
|
18
|
+
def initialize(page)
|
19
|
+
@page = page
|
20
|
+
end
|
15
21
|
|
16
22
|
# @return [Integer] total test result count
|
17
23
|
def total_tests_count
|
18
24
|
failed_count + passed_count
|
19
25
|
end
|
20
26
|
|
21
|
-
def parse_page(
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
27
|
+
def parse_page(with_describe_info = true)
|
28
|
+
return self unless valid_html?
|
29
|
+
|
30
|
+
@describe = fetch_describe if with_describe_info
|
31
|
+
@processing = fetch_processing
|
32
|
+
@result = fetch_total_result
|
33
|
+
@time = fetch_total_time
|
34
|
+
@total = fetch_totals
|
35
|
+
@failed_count = fetch_failed_count
|
36
|
+
@passed_count = fetch_passed_count
|
37
|
+
@pending_count = fetch_pending_count
|
30
38
|
self
|
31
39
|
end
|
32
40
|
|
41
|
+
# @return [True, False] is html code is valid
|
42
|
+
def valid_html?
|
43
|
+
return false unless page.at_css('div.results')
|
44
|
+
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
33
48
|
private
|
34
49
|
|
35
|
-
def
|
50
|
+
def fetch_describe
|
36
51
|
results = ResultCreator.new
|
37
52
|
page.at_css('div.results').xpath('./div').each do |current|
|
38
53
|
results.push_to_end(parse_describe(current),
|
39
|
-
|
54
|
+
fetch_describe_level(current))
|
40
55
|
end
|
41
56
|
results.final_result
|
42
57
|
end
|
@@ -52,14 +67,14 @@ module OnlyofficeRspecResultParser
|
|
52
67
|
describe_obj
|
53
68
|
end
|
54
69
|
|
55
|
-
def
|
70
|
+
def fetch_describe_level(describe)
|
56
71
|
style_string = describe.xpath('./dl')[0][:style]
|
57
72
|
style_parameter = StringHelper.get_style_param(style_string,
|
58
73
|
'margin-left')
|
59
74
|
StringHelper.delete_px(style_parameter).to_i / LEVEL_MARGIN
|
60
75
|
end
|
61
76
|
|
62
|
-
def
|
77
|
+
def fetch_processing
|
63
78
|
processing = page.css('script:contains("moveProgressBar")').last
|
64
79
|
return '0' unless processing
|
65
80
|
|
@@ -71,11 +86,11 @@ module OnlyofficeRspecResultParser
|
|
71
86
|
end
|
72
87
|
end
|
73
88
|
|
74
|
-
def
|
75
|
-
|
89
|
+
def fetch_total_result
|
90
|
+
fetch_totals.include?(' 0 failures')
|
76
91
|
end
|
77
92
|
|
78
|
-
def
|
93
|
+
def fetch_totals
|
79
94
|
totals = ''
|
80
95
|
total_elem = page.css('script:contains(" example")')
|
81
96
|
return totals unless total_elem
|
@@ -88,19 +103,19 @@ module OnlyofficeRspecResultParser
|
|
88
103
|
end
|
89
104
|
end
|
90
105
|
|
91
|
-
def
|
106
|
+
def fetch_failed_count
|
92
107
|
page.xpath("//*[@class='example failed']").length
|
93
108
|
end
|
94
109
|
|
95
|
-
def
|
110
|
+
def fetch_passed_count
|
96
111
|
page.xpath("//*[@class='example passed']").length
|
97
112
|
end
|
98
113
|
|
99
|
-
def
|
114
|
+
def fetch_pending_count
|
100
115
|
page.xpath("//*[@class='example not_implemented']").length
|
101
116
|
end
|
102
117
|
|
103
|
-
def
|
118
|
+
def fetch_total_time
|
104
119
|
total_time = page.css('script:contains("Finished in")')
|
105
120
|
.text
|
106
121
|
.match(/>(.*?)</)
|
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.
|
4
|
+
version: 0.1.2
|
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
|
13
|
+
date: 2020-04-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|