allure-ruby-commons 2.19.0 → 2.21.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 +4 -4
- data/README.md +4 -0
- data/lib/allure-ruby-commons.rb +1 -1
- data/lib/allure_ruby_commons/_json_helper.rb +45 -0
- data/lib/allure_ruby_commons/file_writer.rb +5 -5
- data/lib/allure_ruby_commons/model/01_jsonable.rb +8 -2
- data/lib/allure_ruby_commons/testplan.rb +3 -3
- metadata +11 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66e09f6d14fc5e93508a0d861d0df40b93b76e86a9b89a1ab8d6a5f72a0e036a
|
4
|
+
data.tar.gz: d81cc78375aac9293ffa6f23a35a9ae3dfb8a4a923b20dfddcbae74ce5f8d0be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c37fb24ee8dde0d460a3bcef86c2e515421d09ca22579f249320662542ceaa6cc506c8db017c5e1808dd1b24f428db0e4a258c7be20132c2044f271208959cb2
|
7
|
+
data.tar.gz: dff9c7508de915a8e834d6715bb25883e5607279e3716d73aa42d502801dde3c1cb274c21d8d7a4081298de5896e74055253c7f6b70460bb36dce992dabc68cf
|
data/README.md
CHANGED
@@ -104,3 +104,7 @@ class TestHelper
|
|
104
104
|
def standard_method; end
|
105
105
|
end
|
106
106
|
```
|
107
|
+
|
108
|
+
## JSON parsing
|
109
|
+
|
110
|
+
Internally, allure-ruby-common produces JSON files. To improve performance, [oj](https://www.ohler.com/oj/) gem is used for parsing and generating JSON files if it is available. Otherwise default ruby json implementation is used.
|
data/lib/allure-ruby-commons.rb
CHANGED
@@ -225,7 +225,7 @@ module Allure
|
|
225
225
|
lifecycle.update_test_step { |step| step.status = Status::PASSED }
|
226
226
|
|
227
227
|
result
|
228
|
-
rescue StandardError => e
|
228
|
+
rescue StandardError, RSpec::Expectations::ExpectationNotMetError => e
|
229
229
|
lifecycle.update_test_step do |step|
|
230
230
|
step.status = ResultUtils.status(e)
|
231
231
|
step.status_details = ResultUtils.status_details(e)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Allure
|
4
|
+
# Json helper methods
|
5
|
+
#
|
6
|
+
# @!method dump_json(obj)
|
7
|
+
# Dump object to json using Oj or JSON
|
8
|
+
# @param [Hash] obj
|
9
|
+
# @return [String]
|
10
|
+
# @!method load_json(json)
|
11
|
+
# Load json from file using Oj or JSON
|
12
|
+
# @param [String] json
|
13
|
+
# @return [Hash]
|
14
|
+
# @!method json_parse_error
|
15
|
+
# Json parse error class
|
16
|
+
# @return [Class]
|
17
|
+
module JsonHelper
|
18
|
+
# @return [Hash] Oj json options
|
19
|
+
OJ_OPTIONS = { mode: :custom, use_to_hash: true, ascii_only: true }.freeze
|
20
|
+
|
21
|
+
begin
|
22
|
+
require "oj"
|
23
|
+
|
24
|
+
define_method(:dump_json) do |obj|
|
25
|
+
Oj.dump(obj, OJ_OPTIONS)
|
26
|
+
end
|
27
|
+
|
28
|
+
define_method(:load_json) do |json|
|
29
|
+
Oj.load_file(json, symbol_keys: true)
|
30
|
+
rescue Oj::ParseError
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
define_method(:dump_json) do |obj|
|
35
|
+
JSON.generate(obj)
|
36
|
+
end
|
37
|
+
|
38
|
+
define_method(:load_json) do |json|
|
39
|
+
JSON.parse(File.read(json), symbolize_names: true)
|
40
|
+
rescue JSON::ParserError
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Allure
|
4
4
|
# Allure result file writer
|
5
5
|
class FileWriter
|
6
|
+
include JsonHelper
|
7
|
+
|
6
8
|
# @return [String] test result suffix
|
7
9
|
TEST_RESULT_SUFFIX = "-result.json"
|
8
10
|
# @return [String] test result container suffix
|
@@ -13,8 +15,6 @@ module Allure
|
|
13
15
|
ENVIRONMENT_FILE = "environment.properties"
|
14
16
|
# @return [String] categories definition json
|
15
17
|
CATEGORIES_FILE = "categories.json"
|
16
|
-
# @return [Hash] Oj json options
|
17
|
-
OJ_OPTIONS = { mode: :custom, use_to_hash: true, ascii_only: true }.freeze
|
18
18
|
|
19
19
|
# File writer instance
|
20
20
|
#
|
@@ -27,14 +27,14 @@ module Allure
|
|
27
27
|
# @param [Allure::TestResult] test_result
|
28
28
|
# @return [void]
|
29
29
|
def write_test_result(test_result)
|
30
|
-
write("#{test_result.uuid}#{TEST_RESULT_SUFFIX}",
|
30
|
+
write("#{test_result.uuid}#{TEST_RESULT_SUFFIX}", dump_json(test_result))
|
31
31
|
end
|
32
32
|
|
33
33
|
# Write test result container
|
34
34
|
# @param [Allure::TestResultContainer] test_container_result
|
35
35
|
# @return [void]
|
36
36
|
def write_test_result_container(test_container_result)
|
37
|
-
write("#{test_container_result.uuid}#{TEST_RESULT_CONTAINER_SUFFIX}",
|
37
|
+
write("#{test_container_result.uuid}#{TEST_RESULT_CONTAINER_SUFFIX}", dump_json(test_container_result))
|
38
38
|
end
|
39
39
|
|
40
40
|
# Write allure attachment file
|
@@ -61,7 +61,7 @@ module Allure
|
|
61
61
|
if categories.is_a?(File)
|
62
62
|
copy(categories.path, CATEGORIES_FILE)
|
63
63
|
else
|
64
|
-
write(CATEGORIES_FILE,
|
64
|
+
write(CATEGORIES_FILE, dump_json(categories.map(&:to_hash)))
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "oj"
|
4
|
-
|
5
3
|
module Allure
|
6
4
|
# General jsonable object implementation
|
7
5
|
class JSONable
|
@@ -15,6 +13,14 @@ module Allure
|
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
16
|
+
# Return object json string
|
17
|
+
#
|
18
|
+
# @param [Array] *options
|
19
|
+
# @return [String]
|
20
|
+
def to_json(*options)
|
21
|
+
to_hash.to_json(*options)
|
22
|
+
end
|
23
|
+
|
18
24
|
# Object comparator
|
19
25
|
# @param [JSONable] other
|
20
26
|
# @return [Booelan]
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Allure
|
4
4
|
class TestPlan
|
5
|
+
extend JsonHelper
|
6
|
+
|
5
7
|
# @return [String] test plan path env var name
|
6
8
|
TESTPLAN_PATH = "ALLURE_TESTPLAN_PATH"
|
7
9
|
|
@@ -26,9 +28,7 @@ module Allure
|
|
26
28
|
#
|
27
29
|
# @return [Array<Hash>]
|
28
30
|
def tests
|
29
|
-
@tests ||=
|
30
|
-
rescue Oj::ParseError
|
31
|
-
nil
|
31
|
+
@tests ||= load_json(ENV[TESTPLAN_PATH])&.fetch(:tests) if ENV[TESTPLAN_PATH]
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allure-ruby-commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrejs Cunskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -31,12 +31,12 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: require_all
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '2'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '4'
|
@@ -46,30 +46,24 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '2'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '4'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: rspec-expectations
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - "
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '2'
|
60
|
-
- - "<"
|
57
|
+
- - "~>"
|
61
58
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
59
|
+
version: '3.12'
|
63
60
|
type: :runtime
|
64
61
|
prerelease: false
|
65
62
|
version_requirements: !ruby/object:Gem::Requirement
|
66
63
|
requirements:
|
67
|
-
- - "
|
64
|
+
- - "~>"
|
68
65
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
70
|
-
- - "<"
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: '4'
|
66
|
+
version: '3.12'
|
73
67
|
- !ruby/object:Gem::Dependency
|
74
68
|
name: uuid
|
75
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,6 +93,7 @@ extra_rdoc_files: []
|
|
99
93
|
files:
|
100
94
|
- README.md
|
101
95
|
- lib/allure-ruby-commons.rb
|
96
|
+
- lib/allure_ruby_commons/_json_helper.rb
|
102
97
|
- lib/allure_ruby_commons/allure_lifecycle.rb
|
103
98
|
- lib/allure_ruby_commons/config.rb
|
104
99
|
- lib/allure_ruby_commons/file_writer.rb
|