allure-ruby-commons 2.13.4 → 2.13.6.1
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 +7 -7
- data/lib/allure-ruby-commons.rb +9 -9
- data/lib/allure_ruby_commons/allure_lifecycle.rb +2 -12
- data/lib/allure_ruby_commons/config.rb +10 -9
- data/lib/allure_ruby_commons/file_writer.rb +1 -1
- data/lib/allure_ruby_commons/model/category.rb +1 -1
- data/lib/allure_ruby_commons/model/jsonable.rb +14 -0
- data/lib/allure_ruby_commons/result_utils.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a81d940f25f1d5ce8c0182f5db774847543a9f5f27adafd11ba3097d7f35799b
|
4
|
+
data.tar.gz: 5f15450ce98e2bd96fb56963bfd4ec7531bb7fa363ab783c5a2c3617d4d1b7de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1654746b1f49194bb3bcda1185b8b69a78c869e51adbbac8a8e740052b454b38e48a3082c58bb2f912cbabc4321340e08949adc8f5c52754bf01c72b7e9b472b
|
7
|
+
data.tar.gz: aaeeb44926a120ec16c592724043db8e48e62822f9dee29ae9825d2f22468d64f49f41871fd670f2b90843df2d1b3984987bc1ae2a13fdaccee62b86d3b71ada
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ you can just create the report of any other kind using the basic Allure terms.
|
|
11
11
|
Add the dependency to your Gemfile
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem
|
14
|
+
gem "allure-ruby-commons"
|
15
15
|
```
|
16
16
|
|
17
17
|
## Configuration
|
@@ -19,13 +19,13 @@ Add the dependency to your Gemfile
|
|
19
19
|
Following configuration options are supported:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
Allure.configure do |
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
Allure.configure do |config|
|
23
|
+
config.results_directory = "/whatever/you/like"
|
24
|
+
config.clean_results_directory = true
|
25
|
+
config.logging_level = Logger::INFO
|
26
26
|
# these are used for creating links to bugs or test cases where {} is replaced with keys of relevant items
|
27
|
-
|
28
|
-
|
27
|
+
config.link_tms_pattern = "http://www.jira.com/browse/{}"
|
28
|
+
config.link_issue_pattern = "http://www.jira.com/browse/{}"
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
data/lib/allure-ruby-commons.rb
CHANGED
@@ -9,30 +9,30 @@ require_rel "allure_ruby_commons/**/*rb"
|
|
9
9
|
module Allure
|
10
10
|
class << self
|
11
11
|
# Get thread specific allure lifecycle object
|
12
|
-
# @return [
|
12
|
+
# @return [AllureLifecycle]
|
13
13
|
def lifecycle
|
14
14
|
Thread.current[:lifecycle] ||= AllureLifecycle.new
|
15
15
|
end
|
16
16
|
|
17
17
|
# Set lifecycle object
|
18
|
-
# @param [
|
18
|
+
# @param [AllureLifecycle] lifecycle
|
19
19
|
# @return [void]
|
20
20
|
def lifecycle=(lifecycle)
|
21
21
|
Thread.current[:lifecycle] = lifecycle
|
22
22
|
end
|
23
23
|
|
24
24
|
# Get allure configuration
|
25
|
-
# @return [
|
25
|
+
# @return [Config]
|
26
26
|
def configuration
|
27
|
-
Config
|
27
|
+
Config.instance
|
28
28
|
end
|
29
29
|
|
30
30
|
# Set allure configuration
|
31
|
-
# @yieldparam [
|
31
|
+
# @yieldparam [Config]
|
32
32
|
# @yieldreturn [void]
|
33
33
|
# @return [void]
|
34
34
|
def configure
|
35
|
-
yield(
|
35
|
+
yield(configuration)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Add epic to current test case
|
@@ -131,7 +131,7 @@ module Allure
|
|
131
131
|
# Add attachment to current test case or step
|
132
132
|
# @param [String] name Attachment name
|
133
133
|
# @param [File, String] source File or string to save as attachment
|
134
|
-
# @param [String] type attachment type defined in {
|
134
|
+
# @param [String] type attachment type defined in {ContentType} or any other valid mime type
|
135
135
|
# @param [Boolean] test_case add attachment to current test case instead of test step
|
136
136
|
# @return [void]
|
137
137
|
def add_attachment(name:, source:, type:, test_case: false)
|
@@ -146,7 +146,7 @@ module Allure
|
|
146
146
|
end
|
147
147
|
|
148
148
|
# Add categories info
|
149
|
-
# @param [File, Array<
|
149
|
+
# @param [File, Array<Category>] categories
|
150
150
|
# @return [void]
|
151
151
|
def add_categories(categories)
|
152
152
|
lifecycle.write_categories(categories)
|
@@ -154,7 +154,7 @@ module Allure
|
|
154
154
|
|
155
155
|
# Add step with provided name and optional status to current test step, fixture or test case
|
156
156
|
# @param [String] name
|
157
|
-
# @param [Symbol] status
|
157
|
+
# @param [Symbol] status {Status}, {Status::PASSED} by default
|
158
158
|
# @return [void]
|
159
159
|
def step(name:, status: nil)
|
160
160
|
lifecycle.add_test_step(StepResult.new(name: name, status: status || Status::PASSED, stage: Stage::FINISHED))
|
@@ -11,7 +11,7 @@ module Allure
|
|
11
11
|
def initialize
|
12
12
|
@test_context = []
|
13
13
|
@step_context = []
|
14
|
-
@logger = Logger.new(STDOUT, level: Config.logging_level)
|
14
|
+
@logger = Logger.new(STDOUT, level: Config.instance.logging_level)
|
15
15
|
@file_writer = FileWriter.new
|
16
16
|
end
|
17
17
|
|
@@ -195,7 +195,7 @@ module Allure
|
|
195
195
|
# @param [Boolean] test_case add attachment to current test case
|
196
196
|
# @return [void]
|
197
197
|
def add_attachment(name:, source:, type:, test_case: false)
|
198
|
-
attachment = prepare_attachment(name, type) || begin
|
198
|
+
attachment = ResultUtils.prepare_attachment(name, type) || begin
|
199
199
|
return logger.error("Can't add attachment, unrecognized mime type: #{type}")
|
200
200
|
end
|
201
201
|
executable_item = (test_case && @current_test_case) || current_executable
|
@@ -205,16 +205,6 @@ module Allure
|
|
205
205
|
write_attachment(source, attachment)
|
206
206
|
end
|
207
207
|
|
208
|
-
# Create attachment object
|
209
|
-
# @param [String] name
|
210
|
-
# @param [String] type
|
211
|
-
# @return [Allure::Attachment]
|
212
|
-
def prepare_attachment(name, type)
|
213
|
-
extension = ContentType.to_extension(type) || return
|
214
|
-
file_name = "#{UUID.generate}-attachment.#{extension}"
|
215
|
-
Attachment.new(name: name, source: file_name, type: type)
|
216
|
-
end
|
217
|
-
|
218
208
|
# Add step to current fixture|step|test case
|
219
209
|
# @param [Allure::StepResult] step_result
|
220
210
|
# @return [Allure::StepResult]
|
@@ -1,26 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "logger"
|
4
|
+
require "singleton"
|
4
5
|
|
5
6
|
module Allure
|
6
7
|
# Allure configuration class
|
7
8
|
class Config
|
9
|
+
include Singleton
|
10
|
+
|
8
11
|
# @return [String] default allure results directory
|
9
12
|
DEFAULT_RESULTS_DIRECTORY = "reports/allure-results"
|
10
13
|
# @return [String] default loggin level
|
11
14
|
DEFAULT_LOGGING_LEVEL = Logger::INFO
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
attr_writer :results_directory, :logging_level
|
16
|
+
attr_accessor :link_tms_pattern, :link_issue_pattern, :clean_results_directory
|
17
|
+
attr_writer :results_directory, :logging_level
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
def results_directory
|
20
|
+
@results_directory || DEFAULT_RESULTS_DIRECTORY
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
23
|
+
def logging_level
|
24
|
+
@logging_level || DEFAULT_LOGGING_LEVEL
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -5,6 +5,9 @@ require "json"
|
|
5
5
|
module Allure
|
6
6
|
# General jsonable object implementation
|
7
7
|
class JSONable
|
8
|
+
# Return object has represantation
|
9
|
+
# @param [Hash] _options
|
10
|
+
# @return [Hash]
|
8
11
|
def as_json(_options = {})
|
9
12
|
instance_variables.each_with_object({}) do |var, map|
|
10
13
|
key = camelcase(var.to_s.delete_prefix("@"))
|
@@ -13,22 +16,33 @@ module Allure
|
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
19
|
+
# Convert object to json string
|
20
|
+
# @param [Array<Object>] options
|
21
|
+
# @return [String]
|
16
22
|
def to_json(*options)
|
17
23
|
as_json(*options).to_json(*options)
|
18
24
|
end
|
19
25
|
|
26
|
+
# Object comparator
|
27
|
+
# @param [JSONable] other
|
28
|
+
# @return [Booelan]
|
20
29
|
def ==(other)
|
21
30
|
self.class == other.class && state == other.state
|
22
31
|
end
|
23
32
|
|
24
33
|
protected
|
25
34
|
|
35
|
+
# Object state
|
36
|
+
# @return [Array]
|
26
37
|
def state
|
27
38
|
instance_variables.map { |var| instance_variable_get(var) }
|
28
39
|
end
|
29
40
|
|
30
41
|
private
|
31
42
|
|
43
|
+
# Covert string to camelcase
|
44
|
+
# @param [String] str
|
45
|
+
# @return [String]
|
32
46
|
def camelcase(str)
|
33
47
|
str = str.gsub(/(?:_+)([a-z])/) { Regexp.last_match(1).upcase }
|
34
48
|
str.gsub(/(\A|\s)([A-Z])/) { Regexp.last_match(1) + Regexp.last_match(2).downcase }
|
@@ -46,10 +46,15 @@ module Allure
|
|
46
46
|
Label.new(HOST_LABEL_NAME, Socket.gethostname)
|
47
47
|
end
|
48
48
|
|
49
|
+
# Language label
|
50
|
+
# @return [Allure::Label]
|
49
51
|
def language_label
|
50
52
|
Label.new(LANGUAGE_LABEL_NAME, "ruby")
|
51
53
|
end
|
52
54
|
|
55
|
+
# Framework label
|
56
|
+
# @param [String] value
|
57
|
+
# @return [Allure::Label]
|
53
58
|
def framework_label(value)
|
54
59
|
Label.new(FRAMEWORK_LABEL_NAME, value)
|
55
60
|
end
|
@@ -145,6 +150,16 @@ module Allure
|
|
145
150
|
StatusDetails.new(message: exception&.message, trace: exception&.backtrace&.join("\n"))
|
146
151
|
end
|
147
152
|
|
153
|
+
# Allure attachment object
|
154
|
+
# @param [String] name
|
155
|
+
# @param [String] type
|
156
|
+
# @return [Allure::Attachment]
|
157
|
+
def prepare_attachment(name, type)
|
158
|
+
extension = ContentType.to_extension(type) || return
|
159
|
+
file_name = "#{UUID.generate}-attachment.#{extension}"
|
160
|
+
Attachment.new(name: name, source: file_name, type: type)
|
161
|
+
end
|
162
|
+
|
148
163
|
private
|
149
164
|
|
150
165
|
def tms_url(value)
|
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.13.
|
4
|
+
version: 2.13.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrejs Cunskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuid
|