allure-ruby-commons 2.13.3 → 2.13.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/allure-ruby-commons.rb +10 -9
- data/lib/allure_ruby_commons/allure_lifecycle.rb +4 -18
- 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 +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12cb6b2b1132dd43b17becb6b9a32c47cb9aa44a3be793dc09f083d7e5784370
|
4
|
+
data.tar.gz: a34abfd6a9dff13b8b6b1d571b33f348549c59848579220c4a8add6d5317004c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d6bf42ce012302f708869666f94ea4a8a408dc2c17f4989e2b469b3a100458a36226d5b9790ba497b4b69c87306ee437f6825187255f1c00dc9d1a579e5d322
|
7
|
+
data.tar.gz: f15cadf664ae40f2152a86f541bd2a3ef68de4bc60bc72908b04ace4a90753088a6342a3eb63846a95a38b5e311c573223fe5d901fc29c78b2f4cd76f5958ddc
|
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,10 +154,11 @@ 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))
|
161
|
+
lifecycle.stop_test_step
|
161
162
|
end
|
162
163
|
|
163
164
|
# Run passed block as step with given name
|
@@ -11,6 +11,8 @@ module Allure
|
|
11
11
|
def initialize
|
12
12
|
@test_context = []
|
13
13
|
@step_context = []
|
14
|
+
@logger = Logger.new(STDOUT, level: Config.instance.logging_level)
|
15
|
+
@file_writer = FileWriter.new
|
14
16
|
end
|
15
17
|
|
16
18
|
def_delegators :file_writer, :write_attachment, :write_environment, :write_categories
|
@@ -193,7 +195,7 @@ module Allure
|
|
193
195
|
# @param [Boolean] test_case add attachment to current test case
|
194
196
|
# @return [void]
|
195
197
|
def add_attachment(name:, source:, type:, test_case: false)
|
196
|
-
attachment = prepare_attachment(name, type) || begin
|
198
|
+
attachment = ResultUtils.prepare_attachment(name, type) || begin
|
197
199
|
return logger.error("Can't add attachment, unrecognized mime type: #{type}")
|
198
200
|
end
|
199
201
|
executable_item = (test_case && @current_test_case) || current_executable
|
@@ -203,16 +205,6 @@ module Allure
|
|
203
205
|
write_attachment(source, attachment)
|
204
206
|
end
|
205
207
|
|
206
|
-
# Create attachment object
|
207
|
-
# @param [String] name
|
208
|
-
# @param [String] type
|
209
|
-
# @return [Allure::Attachment]
|
210
|
-
def prepare_attachment(name, type)
|
211
|
-
extension = ContentType.to_extension(type) || return
|
212
|
-
file_name = "#{UUID.generate}-attachment.#{extension}"
|
213
|
-
Attachment.new(name: name, source: file_name, type: type)
|
214
|
-
end
|
215
|
-
|
216
208
|
# Add step to current fixture|step|test case
|
217
209
|
# @param [Allure::StepResult] step_result
|
218
210
|
# @return [Allure::StepResult]
|
@@ -232,13 +224,7 @@ module Allure
|
|
232
224
|
|
233
225
|
private
|
234
226
|
|
235
|
-
|
236
|
-
@logger ||= Logger.new(STDOUT, level: Config.logging_level)
|
237
|
-
end
|
238
|
-
|
239
|
-
def file_writer
|
240
|
-
@file_writer ||= FileWriter.new
|
241
|
-
end
|
227
|
+
attr_accessor :logger, :file_writer
|
242
228
|
|
243
229
|
def current_executable
|
244
230
|
current_test_step || @current_fixture || @current_test_case
|
@@ -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
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuid
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
133
|
+
rubygems_version: 3.1.2
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Common library for allure results generation
|