allure-ruby-commons 2.14.2 → 2.15.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: 167b883e345ddf9b55cf96986f203371ea865bc470212f578e906989d10d3ea0
4
- data.tar.gz: a7568ffb62caa98ac0e74c836630493b5ae228d2e4ff7ed7707be0862b4b012b
3
+ metadata.gz: 284b37ad75460156a0b06aa8725ae5687b69a6ee7aa9a59691cf5148e51b1db0
4
+ data.tar.gz: e635323b10208124ee787334132bde0c714fb70e42b1b969595e6c35e0eb989e
5
5
  SHA512:
6
- metadata.gz: 974f8f097b193e9abfa0f17c1dadbcf4592f87734512a579540389982e5c05d3ef9bc68b22f5971c479a3279044195b46cce3b20ad010275b900d5a5c7919ae9
7
- data.tar.gz: 36ffc3d9a9c9dfdc4ba4f03699fdb49d74e2db4f076404c698170dd0d95384876930c3150a39fe5381b7ea6d82dc692d9d451199194d4d808ef6084a97d76f55
6
+ metadata.gz: 2c90af87fa423669ec1bf027bbd32f316a567df317f9d07ea03a9dab86107f2753609f00208510bb1ca9b4f5c4f71a20cfda08f4332ad2f667bfb8053be4fb08
7
+ data.tar.gz: 56bf9f7d9ea0ae31d8b35749d999a9b2a98d3dca0de6ee27124a428402a2d152a2c6b7874faa2f3b97e363155debfcea9b7ad2d76b40199eed7e6f663f322059
data/README.md CHANGED
@@ -53,6 +53,22 @@ It is possible to set up custom allure environment which will be used as custom
53
53
  * via `ALLURE_ENVIRONMENT` environment variable
54
54
  * via `configure` method
55
55
 
56
+ ### Environment properties
57
+
58
+ To add additional environment information to the report it is possible to set configuration property `environment_properties`.
59
+
60
+ Option can be set to hash or block returning a hash:
61
+
62
+ ```ruby
63
+ # hash
64
+ config.environment_properties = {
65
+ custom_attribute: "foo"
66
+ }
67
+
68
+ # lambda
69
+ config.environment_properties = -> { { custom_attributes: "foo"} }
70
+ ```
71
+
56
72
  ### Log level
57
73
 
58
74
  Log level can be also configured via environment variable `ALLURE_LOG_LEVEL` which accepts one of the following values: `DEBUG INFO WARN ERROR FATAL UNKNOWN`.
@@ -164,7 +164,7 @@ module Allure
164
164
  # Manually create environment.properties file
165
165
  # if this method is called before test run started and
166
166
  # option clean_results_directory is enabled, the file will be deleted
167
- # @param [Hash<Symbol, String>] environment
167
+ # @param [Hash<Symbol, String>, Proc] environment
168
168
  # @return [void]
169
169
  def add_environment(environment)
170
170
  lifecycle.write_environment(environment)
@@ -223,12 +223,13 @@ module Allure
223
223
 
224
224
  # Add environment.properties file
225
225
  #
226
- # @param [Hash] env
226
+ # @param [Hash, Proc] env
227
227
  # @return [void]
228
228
  def write_environment(env = config.environment_properties)
229
229
  return unless env
230
230
 
231
- file_writer.write_environment(env)
231
+ env_properties = env.respond_to?(:call) ? env.call : env
232
+ file_writer.write_environment(env_properties)
232
233
  end
233
234
 
234
235
  # Add categories.json
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "socket"
4
+ require "uri"
4
5
 
5
6
  module Allure
6
7
  # Variouse helper methods
@@ -133,16 +134,18 @@ module Allure
133
134
  # @param [String] value
134
135
  # @param [String] link_pattern
135
136
  # @return [Allure::Link]
136
- def tms_link(value, link_pattern)
137
- Link.new(TMS_LINK_TYPE, value, url(value, link_pattern))
137
+ def tms_link(name, value, link_pattern)
138
+ link_name = url?(value) ? name : value
139
+ Link.new(TMS_LINK_TYPE, link_name, url(value, link_pattern))
138
140
  end
139
141
 
140
142
  # Issue link
141
143
  # @param [String] value
142
144
  # @param [String] link_pattern
143
145
  # @return [Allure::Link]
144
- def issue_link(value, link_pattern)
145
- Link.new(ISSUE_LINK_TYPE, value, url(value, link_pattern))
146
+ def issue_link(name, value, link_pattern)
147
+ link_name = url?(value) ? name : value
148
+ Link.new(ISSUE_LINK_TYPE, link_name, url(value, link_pattern))
146
149
  end
147
150
 
148
151
  # Get status based on exception type
@@ -171,6 +174,19 @@ module Allure
171
174
 
172
175
  private
173
176
 
177
+ # Check if value is full url
178
+ #
179
+ # @param [String] value
180
+ # @return [Boolean]
181
+ def url?(value)
182
+ URI.parse(value.to_s).scheme
183
+ end
184
+
185
+ # Construct url from pattern
186
+ #
187
+ # @param [String] value
188
+ # @param [String] link_pattern
189
+ # @return [String]
174
190
  def url(value, link_pattern)
175
191
  link_pattern.sub("{}", value)
176
192
  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.14.2
4
+ version: 2.15.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: 2021-07-14 00:00:00.000000000 Z
11
+ date: 2021-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types