allure-ruby-commons 2.13.0 → 2.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f87a04ab08ca894c406ea456552a64243acc4b91beb359e4c4673efc27c5b2e4
4
- data.tar.gz: ce8af253d321e87a8115afb86df0e5d882555469de95969abac529c2b7b4c8c3
3
+ metadata.gz: 5a9115fbeeca5e229495d548047fa91edac5cb364a3a18c629f7d860fff43b3c
4
+ data.tar.gz: 302ce724cd87c8c8a392687355c693774e40e0dfeb6d00cc4e67c5202a2dd733
5
5
  SHA512:
6
- metadata.gz: dd99f1bb1d1d4fd31d0a3bdd91a4752f2105f17149e73a3c2b031a03741eab5483557b50bb45e7af52e016620390fe820866937605724587baa15f0d1a4a61b4
7
- data.tar.gz: 063dc9cd0a43cfa264396d7c21b26d2080233fb8d89eba446602c51243af305774c99b9e0553d3f6f51c483d35f8bfb1ad3ae7ff7ad3463f0820e20d11c53150
6
+ metadata.gz: 7392a3abf6e355d4e1a7e1dfddca5c39c68ffe89549eaf72db2a0e7e4793c4019e7f2dfb5877c82be92775476ac70349218e1c85087ed17aa7374a0d6c461beb
7
+ data.tar.gz: 9a263ffc1763bbb4647c5341259bf12f6e8e766feb026fc4f7fae41c51b109609b64b410baaadb0080f9bd07edfccb113ffb47553e5ddbf7632770188ed8190a
@@ -76,7 +76,7 @@ module Allure
76
76
  # Add description to current test case
77
77
  # @param [String] description
78
78
  # @return [void]
79
- def description(description)
79
+ def add_description(description)
80
80
  lifecycle.update_test_case do |test_case|
81
81
  test_case.description = description
82
82
  end
@@ -1,9 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "fileutils"
4
+
3
5
  module Allure
4
6
  # Main class for creating and writing allure results
5
7
  class AllureLifecycle
6
8
  def initialize
9
+ @test_context = []
7
10
  @step_context = []
8
11
  end
9
12
 
@@ -11,8 +14,10 @@ module Allure
11
14
  # @param [Allure::TestResultContainer] test_result_container
12
15
  # @return [Allure::TestResultContainer]
13
16
  def start_test_container(test_result_container)
14
- test_result_container.start = ResultUtils.timestamp
15
- @current_test_result_container = test_result_container
17
+ test_result_container.tap do |container|
18
+ container.start = ResultUtils.timestamp
19
+ @test_context.push(container)
20
+ end
16
21
  end
17
22
 
18
23
  # @example Update current test container
@@ -23,23 +28,25 @@ module Allure
23
28
  # @yieldreturn [void]
24
29
  # @return [void]
25
30
  def update_test_container
26
- unless @current_test_result_container
31
+ unless current_test_result_container
27
32
  return logger.error("Could not update test container, no container is running.")
28
33
  end
29
34
 
30
- yield(@current_test_result_container)
35
+ yield(current_test_result_container)
31
36
  end
32
37
 
33
38
  # Stop current test container and write result
34
39
  # @return [void]
35
40
  def stop_test_container
36
- unless @current_test_result_container
41
+ unless current_test_result_container
37
42
  return logger.error("Could not stop test container, no container is running.")
38
43
  end
39
44
 
40
- @current_test_result_container.stop = ResultUtils.timestamp
41
- file_writer.write_test_result_container(@current_test_result_container)
42
- clear_current_test_container
45
+ current_test_result_container.tap do |container|
46
+ container.stop = ResultUtils.timestamp
47
+ file_writer.write_test_result_container(container)
48
+ clear_last_test_container
49
+ end
43
50
  end
44
51
 
45
52
  # Start test case and add to current test container
@@ -47,14 +54,14 @@ module Allure
47
54
  # @return [Allure::TestResult]
48
55
  def start_test_case(test_result)
49
56
  clear_step_context
50
- unless @current_test_result_container
57
+ unless current_test_result_container
51
58
  return logger.error("Could not start test case, test container is not started")
52
59
  end
53
60
 
54
61
  test_result.start = ResultUtils.timestamp
55
62
  test_result.stage = Stage::RUNNING
56
63
  test_result.labels.push(ResultUtils.thread_label, ResultUtils.host_label, ResultUtils.language_label)
57
- @current_test_result_container.children.push(test_result.uuid)
64
+ current_test_result_container.children.push(test_result.uuid)
58
65
  @current_test_case = test_result
59
66
  end
60
67
 
@@ -123,7 +130,7 @@ module Allure
123
130
  # @return [Allure::FixtureResult]
124
131
  def start_prepare_fixture(fixture_result)
125
132
  start_fixture(fixture_result) || return
126
- @current_test_result_container.befores.push(fixture_result)
133
+ current_test_result_container.befores.push(fixture_result)
127
134
  @current_fixture = fixture_result
128
135
  end
129
136
 
@@ -132,7 +139,7 @@ module Allure
132
139
  # @return [Allure::FixtureResult]
133
140
  def start_tear_down_fixture(fixture_result)
134
141
  start_fixture(fixture_result) || return
135
- @current_test_result_container.afters.push(fixture_result)
142
+ current_test_result_container.afters.push(fixture_result)
136
143
  @current_fixture = fixture_result
137
144
  end
138
145
 
@@ -141,7 +148,7 @@ module Allure
141
148
  # @return [Allure::FixtureResult]
142
149
  def start_fixture(fixture_result)
143
150
  clear_step_context
144
- unless @current_test_result_container
151
+ unless current_test_result_container
145
152
  logger.error("Could not start fixture, test container is not started")
146
153
  return false
147
154
  end
@@ -218,6 +225,14 @@ module Allure
218
225
  step_result
219
226
  end
220
227
 
228
+ # Clean results directory
229
+ # @return [void]
230
+ def clean_results_dir
231
+ Allure.configuration.tap do |c|
232
+ FileUtils.rm_f(Dir.glob("#{c.results_directory}/*")) if c.clean_results_directory
233
+ end
234
+ end
235
+
221
236
  private
222
237
 
223
238
  def logger
@@ -232,12 +247,12 @@ module Allure
232
247
  current_test_step || @current_fixture || @current_test_case
233
248
  end
234
249
 
235
- def clear_current_test_container
236
- @current_test_result_container = nil
250
+ def current_test_result_container
251
+ @test_context.last
237
252
  end
238
253
 
239
- def clear_current_test_case
240
- @current_test_case = nil
254
+ def clear_last_test_container
255
+ @test_context.pop
241
256
  end
242
257
 
243
258
  def current_test_step
@@ -252,6 +267,10 @@ module Allure
252
267
  @step_context.clear
253
268
  end
254
269
 
270
+ def clear_current_test_case
271
+ @current_test_case = nil
272
+ end
273
+
255
274
  def clear_current_fixture
256
275
  @current_fixture = nil
257
276
  end
@@ -75,6 +75,20 @@ module Allure
75
75
  Label.new(SUITE_LABEL_NAME, value)
76
76
  end
77
77
 
78
+ # Parent suite label
79
+ # @param [String] value
80
+ # @return [Allure::Label]
81
+ def parent_suite_label(value)
82
+ Label.new(PARENT_SUITE_LABEL_NAME, value)
83
+ end
84
+
85
+ # Parent suite label
86
+ # @param [String] value
87
+ # @return [Allure::Label]
88
+ def sub_suite_label(value)
89
+ Label.new(SUB_SUITE_LABEL_NAME, value)
90
+ end
91
+
78
92
  # Story label
79
93
  # @param [String] value
80
94
  # @return [Allure::Label]
@@ -119,16 +133,16 @@ module Allure
119
133
 
120
134
  # Get status based on exception type
121
135
  # @param [Exception] exception
122
- # @return [String]
136
+ # @return [Symbol]
123
137
  def status(exception)
124
138
  expectation_error?(exception) ? Status::FAILED : Status::BROKEN
125
139
  end
126
140
 
127
141
  # Get exception status detail
128
142
  # @param [Exception] exception
129
- # @return [Hash<Symbol, String>]
143
+ # @return [Allure::StatusDetails]
130
144
  def status_details(exception)
131
- StatusDetails.new(message: exception.message, trace: exception.backtrace&.join("\n"))
145
+ StatusDetails.new(message: exception&.message, trace: exception&.backtrace&.join("\n"))
132
146
  end
133
147
 
134
148
  private
@@ -144,8 +158,6 @@ module Allure
144
158
  def expectation_error?(exception)
145
159
  exception.instance_of?(RSpec::Expectations::ExpectationNotMetError) ||
146
160
  exception.instance_of?(RSpec::Expectations::MultipleExpectationsNotMetError)
147
- rescue NameError
148
- false
149
161
  end
150
162
  end
151
163
  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.13.0
4
+ version: 2.13.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: 2019-09-08 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuid
@@ -58,20 +58,6 @@ dependencies:
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3'
61
- - !ruby/object:Gem::Dependency
62
- name: rubyzip
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.2'
68
- type: :runtime
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.2'
75
61
  - !ruby/object:Gem::Dependency
76
62
  name: mime-types
77
63
  requirement: !ruby/object:Gem::Requirement
@@ -113,11 +99,15 @@ files:
113
99
  - lib/allure_ruby_commons/model/test_result.rb
114
100
  - lib/allure_ruby_commons/model/test_result_container.rb
115
101
  - lib/allure_ruby_commons/result_utils.rb
116
- - lib/allure_ruby_commons/util.rb
117
102
  homepage: https://github.com/allure-framework/allure-ruby
118
103
  licenses:
119
104
  - Apache-2.0
120
- metadata: {}
105
+ metadata:
106
+ bug_tracker_uri: https://github.com/allure-framework/allure-ruby/issues
107
+ changelog_uri: https://github.com/allure-framework/allure-ruby/releases
108
+ documentation_uri: https://github.com/allure-framework/allure-ruby/blob/master/allure-ruby-commons/README.md
109
+ source_code_uri: https://github.com/allure-framework/allure-ruby/tree/master/allure-ruby-commons
110
+ wiki_uri: https://github.com/allure-framework/allure-ruby/wiki
121
111
  post_install_message:
122
112
  rdoc_options: []
123
113
  require_paths:
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "open-uri"
4
- require "zip"
5
- require "pathname"
6
-
7
- module Allure
8
- # Utility for downloading allure commandline binary
9
- class Util
10
- # @return [String] CLI version
11
- ALLURE_CLI_VERSION = "2.12.1"
12
- # @return [String] CLI bin download url
13
- ALLURE_BIN_URL = "http://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/"\
14
- "#{ALLURE_CLI_VERSION}/allure-commandline-#{ALLURE_CLI_VERSION}.zip"
15
-
16
- class << self
17
- # Download allure bin if appropriate version is not in path
18
- # @return [String] allure executable
19
- def allure_cli
20
- return "allure" if ALLURE_CLI_VERSION == `allure --version`.chomp
21
-
22
- cli_dir = File.join(".allure", "allure-#{ALLURE_CLI_VERSION}")
23
- zip = File.join(".allure", "allure.zip")
24
- bin = File.join(cli_dir, "bin", "allure")
25
-
26
- FileUtils.mkpath(".allure")
27
- download_allure(zip) unless File.exist?(zip) || File.exist?(bin)
28
- extract_allure(zip, ".allure") unless File.exist?(bin)
29
-
30
- bin
31
- end
32
-
33
- private
34
-
35
- def download_allure(destination)
36
- File.open(destination, "w") { |file| file.write(open(ALLURE_BIN_URL).read) } # rubocop:disable Security/Open
37
- end
38
-
39
- def extract_allure(zip, destination)
40
- Zip::File.foreach(zip) do |entry|
41
- entry.restore_permissions = true
42
- entry.extract(File.join(destination, entry.name))
43
- end
44
- FileUtils.rm(zip)
45
- end
46
- end
47
- end
48
- end