allure-rspec 2.28.0 → 2.32.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: 976bbb8464540667897631469bd8ae7b9e995a4174b4120d361ffd36f013e9ae
4
- data.tar.gz: 97081c64e4e985873af72034cf704c3fb3c2a3094025fa0830c3c858bc1b1dd2
3
+ metadata.gz: 7b1ea18ddb872284ccba7545c9e8b0918b75d765000498381a53a7de2f0a5472
4
+ data.tar.gz: 4d47410b77295618c92416d154744c4f4c0e75449bdb386fb6e05111bce38c60
5
5
  SHA512:
6
- metadata.gz: b377acac69363d54043ace0f5a3daff9acde21d751063933ace20d41b9f158180e4009bddcb0473c94cdd3ae200e57a079f65d4c507884c877fcee9dd88cb0c3
7
- data.tar.gz: 722df27fcaf1094fb6d87a68ab1d5cee2351b299f133536adc3f88494e7cd7099c1e8d87757e64f0e7c336b32c9b3b1f2c5d0c56752ba15b7011e5322c6e1706
6
+ metadata.gz: 999a696e41ef85ae1566aca0879e7ea7704aaf4fdf81c0166387ed5d546286afebad769fac5a2f968dae592d6088a48497d0010c3b09667638138abe6f84dd17
7
+ data.tar.gz: 6546a3ff10044dfb8841f132d677071eb538ea14f0b7306be12d5c11d6dca6a85a972ae6179ac20d6a3803198f75204d011421e09453aef12f5c354575b54c21
data/README.md CHANGED
@@ -30,6 +30,12 @@ AllureRspec.configure do |config|
30
30
  config.logger = Logger.new($stdout, Logger::DEBUG)
31
31
  config.environment = "staging"
32
32
 
33
+ # labels added to every test result
34
+ config.global_labels = [
35
+ { name: "owner", value: "qa" },
36
+ { name: "tag", value: "global" }
37
+ ]
38
+
33
39
  # these are used for creating links to bugs or test cases where {} is replaced with keys of relevant items
34
40
  config.link_tms_pattern = "http://www.jira.com/browse/{}"
35
41
  config.link_issue_pattern = "http://www.jira.com/browse/{}"
@@ -44,6 +50,9 @@ AllureRspec.configure do |config|
44
50
  end
45
51
  ```
46
52
 
53
+ `global_labels` defaults to `[]`. Each entry is a hash with symbol keys `:name` and `:value`.
54
+ Labels are prepended to every completed test's labels without replacing test-specific labels, including those with the same name.
55
+
47
56
  ## Usage
48
57
 
49
58
  Via commandline arguments, simply add:
@@ -15,6 +15,8 @@ module AllureRspec
15
15
  pending: Allure::Status::SKIPPED,
16
16
  passed: Allure::Status::PASSED
17
17
  }.freeze
18
+ ANSI_ESCAPE_PATTERN = /\e\[(\d+)(?:;\d+)*m/
19
+ SUITE_HOOK_FAILURE_PATTERN = /\AAn error occurred in an? `(?:before|after)\(:suite\)` hook\.\z/
18
20
 
19
21
  RSpec::Core::Formatters.register(
20
22
  self,
@@ -23,7 +25,8 @@ module AllureRspec
23
25
  :example_group_started,
24
26
  :example_group_finished,
25
27
  :example_started,
26
- :example_finished
28
+ :example_finished,
29
+ :message
27
30
  )
28
31
 
29
32
  RSpec.configure do |config|
@@ -58,6 +61,7 @@ module AllureRspec
58
61
  # @return [void]
59
62
  def stop(_stop_notification)
60
63
  lifecycle.write_environment
64
+ lifecycle.write_globals
61
65
  end
62
66
 
63
67
  # Starts example group
@@ -92,6 +96,17 @@ module AllureRspec
92
96
  lifecycle.stop_test_container
93
97
  end
94
98
 
99
+ # Capture errors raised by before(:suite) and after(:suite) hooks
100
+ # @param [RSpec::Core::Notifications::MessageNotification] notification
101
+ # @return [void]
102
+ def message(notification)
103
+ formatted_error = notification.message.to_s.gsub(ANSI_ESCAPE_PATTERN, "").strip
104
+ first_line = formatted_error.lines.first&.chomp
105
+ return unless SUITE_HOOK_FAILURE_PATTERN.match?(first_line.to_s)
106
+
107
+ lifecycle.add_global_error(message: first_line, trace: formatted_error)
108
+ end
109
+
95
110
  private
96
111
 
97
112
  attr_reader :lifecycle, :allure_config
@@ -108,6 +123,7 @@ module AllureRspec
108
123
  description_html: "Location - #{strip_relative(parser.location)}",
109
124
  history_id: example.id,
110
125
  full_name: example.full_description,
126
+ title_path: parser.title_path,
111
127
  labels: parser.labels,
112
128
  links: parser.links,
113
129
  status_details: parser.status_details,
@@ -124,7 +140,7 @@ module AllureRspec
124
140
  test_case.stage = Allure::Stage::FINISHED
125
141
  test_case.status = status(result)
126
142
  test_case.status_details.message = status_detail.message
127
- test_case.status_details.trace = status_detail.trace&.gsub(/\e\[(\d+)(?:;\d+)*m/, "")
143
+ test_case.status_details.trace = status_detail.trace&.gsub(ANSI_ESCAPE_PATTERN, "")
128
144
  end
129
145
  end
130
146
  end
@@ -67,6 +67,12 @@ module AllureRspec
67
67
  )
68
68
  end
69
69
 
70
+ # Title path without the final example display name.
71
+ # @return [Array<String>]
72
+ def title_path
73
+ [strip_relative(example.file_path), *SuiteLabels.new(example.example_group).title_path]
74
+ end
75
+
70
76
  # Example location
71
77
  #
72
78
  # @return [String]
@@ -13,9 +13,7 @@ module AllureRspec
13
13
  # Get test suite labels
14
14
  # @return [Array<Allure::Label>]
15
15
  def fetch
16
- parents = example_group.parent_groups.map do |group|
17
- group.description.empty? ? "Anonymous" : group.description
18
- end
16
+ parents = parent_groups
19
17
 
20
18
  labels = []
21
19
  labels << Allure::ResultUtils.suite_label(suite(parents))
@@ -25,10 +23,23 @@ module AllureRspec
25
23
  labels
26
24
  end
27
25
 
26
+ # Get title path from outermost group to innermost group.
27
+ # @return [Array<String>]
28
+ def title_path
29
+ parent_groups.reverse
30
+ end
31
+
28
32
  private
29
33
 
30
34
  attr_reader :example_group
31
35
 
36
+ # @return [Array<String>]
37
+ def parent_groups
38
+ @parent_groups ||= example_group.parent_groups.map do |group|
39
+ group.description.empty? ? "Anonymous" : group.description
40
+ end
41
+ end
42
+
32
43
  # @param [Array<String>] parents
33
44
  # @return [String]
34
45
  def suite(parents)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.28.0
4
+ version: 2.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 2.28.0
18
+ version: 2.32.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 2.28.0
25
+ version: 2.32.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec-core
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  - - "<"
44
44
  - !ruby/object:Gem::Version
45
45
  version: '4'
46
- description: Cucumber adaptor to generate rich allure test reports
46
+ description: Cucumber adapter to generate rich allure test reports
47
47
  email: andrejs.cunskis@gmail.com
48
48
  executables: []
49
49
  extensions: []
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
- rubygems_version: 3.6.9
83
+ rubygems_version: 4.0.20
84
84
  specification_version: 4
85
- summary: Allure rspec ruby adaptor
85
+ summary: Allure rspec ruby adapter
86
86
  test_files: []