allure-rspec 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d0dae51e4db6c27206a0030078093da323272cfe37474a258f9202628bc23dd
4
- data.tar.gz: e007ebdab6c1657dfa63bf2c6c47d6bad790f01f245df579dd41d2e3453b1e22
3
+ metadata.gz: 25e23dd81f6ecb2cd12dab863888d69d2b353003d44cdac2978e1e5ba808c314
4
+ data.tar.gz: f411339041c10eaaed80e56bdbf9b766de22b3ceed683c94eac41afcaeb24728
5
5
  SHA512:
6
- metadata.gz: 45c5a098080a3eb4110bf997dd7f927a38447460fd0882b3e4e2e91f7ddaf76337b93af85ec1ac980c88c4730e2cb299f0428c1cc3dd41559491ab3e0e0b2d33
7
- data.tar.gz: fbd4ed49c73f18ec326f3775d44b58bfc5ce177b747d01872b9f126f7e211aaec7f2bf81046d85a60e27df25f85b00be30e146c6c25d0e48e75bddf079f7af30
6
+ metadata.gz: bb49976110e00089942fcb8093af0238e1a07f94b2e586af9d780db94d4af7aa360278007eb2a4befe5fb51377386278fb43e7933a9705a8b352ece971f8cd3c
7
+ data.tar.gz: 10ab87cf135248292de6678519dc0bce8048c3f3a391e16207ae4b5b30835bc7cc732193e62d27bb064a1c8331a077ab8e82c714efe535187edfc1942946265f
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # allure-rspec
2
+
2
3
  [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/allure-rspec)
3
4
 
4
5
  Allure adapter for [rspec](https://rspec.info/) testing framework
@@ -8,32 +9,45 @@ Allure adapter for [rspec](https://rspec.info/) testing framework
8
9
  Add it to gemfile:
9
10
 
10
11
  ```ruby
11
- gem 'allure-rspec'
12
+ gem "allure-rspec"
12
13
  ```
13
14
 
14
15
  Require in `spec_helper` or any other setup file:
15
16
 
16
17
  ```ruby
17
- require `allure-rspec`
18
+ require "allure-rspec"
18
19
  ```
19
20
 
20
21
  ## Configuration
21
22
 
22
- There are no rspec adapter specific configuration options. Main allure configuration is described [here](https://github.com/allure-framework/allure-ruby/blob/master/allure-ruby-commons/README.md#configuration)
23
+ Following configuration options are supported:
24
+
25
+ ```ruby
26
+ AllureRspec.configure do |config|
27
+ config.results_directory = "/whatever/you/like"
28
+ config.clean_results_directory = true
29
+ config.logging_level = Logger::INFO
30
+ # these are used for creating links to bugs or test cases where {} is replaced with keys of relevant items
31
+ config.link_tms_pattern = "http://www.jira.com/browse/{}"
32
+ config.link_issue_pattern = "http://www.jira.com/browse/{}"
33
+ end
34
+ ```
23
35
 
24
36
  ## Usage
25
37
 
26
- Via commandline, simply add:
38
+ Via commandline arguments, simply add:
27
39
 
28
40
  ```bash
29
41
  --format AllureRspecFormatter
30
42
  ```
31
43
 
32
- RSpec configuration:
44
+ or
45
+
46
+ Via RSpec configuration:
33
47
 
34
48
  ```ruby
35
- RSpec.configure do |c|
36
- c.formatter = AllureRspecFormatter
49
+ RSpec.configure do |config|
50
+ config.formatter = AllureRspecFormatter
37
51
  end
38
52
  ```
39
53
 
@@ -42,8 +56,8 @@ end
42
56
  Configure tms link pattern:
43
57
 
44
58
  ```ruby
45
- Allure.configure do |c|
46
- c.link_tms_pattern = "http://www.jira.com/browse/{}"
59
+ AllureRspec.configure do |config|
60
+ config.link_tms_pattern = "http://www.jira.com/browse/{}"
47
61
  end
48
62
  ```
49
63
 
@@ -68,8 +82,8 @@ end
68
82
  Configure issue link pattern:
69
83
 
70
84
  ```ruby
71
- Allure.configure do |c|
72
- c.link_issue_pattern = "http://www.jira.com/browse/{}"
85
+ AllureRspec.configure do |config|
86
+ config.link_issue_pattern = "http://www.jira.com/browse/{}"
73
87
  end
74
88
  ```
75
89
 
@@ -2,7 +2,27 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "allure-ruby-commons"
5
+ require "allure_rspec/config"
5
6
  require "allure_rspec/formatter"
6
7
 
8
+ module AllureRspec
9
+ class << self
10
+ # Get allure cucumber configuration
11
+ # @return [RspecConfig]
12
+ def configuration
13
+ RspecConfig.instance
14
+ end
15
+
16
+ # Set allure configuration
17
+ # @yieldparam [RspecConfig]
18
+ # @yieldreturn [void]
19
+ # @return [void]
20
+ def configure
21
+ yield(configuration)
22
+ end
23
+ end
24
+ end
25
+
26
+ # Rspec formatter class shorthand
7
27
  AllureRspecFormatter = AllureRspec::RSpecFormatter
8
28
  # rubocop:enable Naming/FileName
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "forwardable"
4
+ require "singleton"
5
+
6
+ module AllureRspec
7
+ # Shorthand configuration class
8
+ class RspecConfig < Allure::Config
9
+ include Singleton
10
+ extend Forwardable
11
+
12
+ def_delegators :@allure_config,
13
+ :clean_results_directory,
14
+ :clean_results_directory=,
15
+ :link_issue_pattern,
16
+ :link_issue_pattern=,
17
+ :link_tms_pattern,
18
+ :link_tms_pattern=,
19
+ :logging_level,
20
+ :logging_level=,
21
+ :results_directory,
22
+ :results_directory=
23
+
24
+ def initialize
25
+ @allure_config = Allure.configuration
26
+ end
27
+ end
28
+ end
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ruby2_keywords"
3
4
  require "rspec/core"
4
5
  require "rspec/core/formatters/base_formatter"
5
6
 
6
7
  require_relative "rspec_model"
7
8
 
9
+ # Main allure-rspec module
8
10
  module AllureRspec
11
+ # Main rspec formatter class translating rspec events to allure lifecycle
9
12
  class RSpecFormatter < RSpec::Core::Formatters::BaseFormatter
10
13
  include AllureRspecModel
11
14
 
@@ -20,7 +23,7 @@ module AllureRspec
20
23
 
21
24
  RSpec::Core::Example.class_eval do
22
25
  Allure.singleton_methods.each do |method|
23
- define_method(method) { |*args, &block| Allure.__send__(method, *args, &block) }
26
+ ruby2_keywords define_method(method) { |*args, &block| Allure.__send__(method, *args, &block) }
24
27
  end
25
28
  end
26
29
 
@@ -56,7 +59,7 @@ module AllureRspec
56
59
  end
57
60
 
58
61
  # Starts example group
59
- # @param [RSpec::Core::Notifications::GroupNotification] example_group_notification
62
+ # @param [RSpec::Core::Notifications::GroupNotification] _example_group_notification
60
63
  # @return [void]
61
64
  def example_group_finished(_example_group_notification)
62
65
  lifecycle.stop_test_container
@@ -6,6 +6,7 @@ require "pathname"
6
6
  require_relative "tag_parser"
7
7
 
8
8
  module AllureRspec
9
+ # Support class for transforming rspec test entities in to allure model entities
9
10
  module AllureRspecModel
10
11
  include TagParser
11
12
 
@@ -48,6 +49,21 @@ module AllureRspec
48
49
 
49
50
  private
50
51
 
52
+ # @param [RSpec::Core::Example] example
53
+ # @return [Array<Allure::Label>]
54
+ def links(example)
55
+ tms_links(example.metadata) + issue_links(example.metadata)
56
+ end
57
+
58
+ # Get allure status from result
59
+ # @param [RSpec::Core::Example::ExecutionResult] result
60
+ # @return [Symbol]
61
+ def status(result)
62
+ return Allure::ResultUtils.status(result.exception) if result.status == :failed
63
+
64
+ ALLURE_STATUS[result.status]
65
+ end
66
+
51
67
  # @param [RSpec::Core::Example] example
52
68
  # @return [Array<Allure::Label>]
53
69
  def labels(example)
@@ -58,8 +74,8 @@ module AllureRspec
58
74
  labels << Allure::ResultUtils.story_label(example.description)
59
75
  labels << Allure::ResultUtils.test_class_label(File.basename(example.file_path, ".rb"))
60
76
  labels << severity(example.metadata)
61
- labels.push(*suite_labels(example.example_group))
62
77
  labels.push(*tag_labels(example.metadata))
78
+ labels.push(*suite_labels(example.example_group))
63
79
  end
64
80
  end
65
81
 
@@ -67,28 +83,30 @@ module AllureRspec
67
83
  # @param [RSpec::Core::ExampleGroup] example_group
68
84
  # @return [Array<Allure::Label>]
69
85
  def suite_labels(example_group)
70
- example_group.parent_groups.map(&:description).yield_self do |parents|
71
- [].tap do |labels|
72
- labels << Allure::ResultUtils.suite_label((parents.length == 1) ? parents.last : parents[-2])
73
- labels << Allure::ResultUtils.parent_suite_label(parents.last) if parents.length > 1
74
- labels << Allure::ResultUtils.sub_suite_label(parents[0..-3].join(" > ")) if parents.length > 2
75
- end
86
+ [].tap do |labels|
87
+ parents = example_group.parent_groups.map(&:description)
88
+ labels << Allure::ResultUtils.suite_label(suite(parents))
89
+ labels << Allure::ResultUtils.parent_suite_label(parent_suite(parents))
90
+ labels << Allure::ResultUtils.sub_suite_label(sub_suites(parents))
76
91
  end
77
92
  end
78
93
 
79
- # @param [RSpec::Core::Example] example
80
- # @return [Array<Allure::Label>]
81
- def links(example)
82
- tms_links(example.metadata) + issue_links(example.metadata)
94
+ # @param [Array<String>] parents
95
+ # @return [String]
96
+ def suite(parents)
97
+ parents.length == 1 ? parents.last : parents[-2]
83
98
  end
84
99
 
85
- # Get allure status from result
86
- # @param [RSpec::Core::Example::ExecutionResult] result
87
- # @return [Symbol]
88
- def status(result)
89
- return Allure::ResultUtils.status(result.exception) if result.status == :failed
100
+ # @param [Array<String>] parents
101
+ # @return [String]
102
+ def parent_suite(parents)
103
+ parents.length > 1 ? parents.last : nil
104
+ end
90
105
 
91
- ALLURE_STATUS[result.status]
106
+ # @param [Array<String>] parents
107
+ # @return [String]
108
+ def sub_suites(parents)
109
+ parents.length > 2 ? parents[0..-3].join(" > ") : nil
92
110
  end
93
111
 
94
112
  # Strip relative ./ form path
@@ -7,27 +7,23 @@ module AllureRspec
7
7
  # @param [Hash] metadata
8
8
  # @return [Array<Allure::Label>]
9
9
  def tag_labels(metadata)
10
- return [] unless Allure::Config.link_tms_pattern && metadata.keys.any? { |k| allure?(k) }
10
+ return [] unless metadata.keys.any? { |k| allure?(k) }
11
11
 
12
- metadata.select { |k, _v| allure?(k) }.values.map { |v| Allure::ResultUtils.tag_label(v) }
12
+ metadata.select { |k| allure?(k) }.values.map { |v| Allure::ResultUtils.tag_label(v) }
13
13
  end
14
14
 
15
15
  # Get tms links
16
16
  # @param [Hash] metadata
17
17
  # @return [Array<Allure::Link>]
18
18
  def tms_links(metadata)
19
- return [] unless Allure::Config.link_tms_pattern && metadata.keys.any? { |k| tms?(k) }
20
-
21
- metadata.select { |k, _v| tms?(k) }.values.map { |v| Allure::ResultUtils.tms_link(v) }
19
+ matching_links(metadata, :tms)
22
20
  end
23
21
 
24
22
  # Get issue links
25
23
  # @param [Hash] metadata
26
24
  # @return [Array<Allure::Link>]
27
25
  def issue_links(metadata)
28
- return [] unless Allure::Config.link_issue_pattern && metadata.keys.any? { |k| issue?(k) }
29
-
30
- metadata.select { |k, _v| issue?(k) }.values.map { |v| Allure::ResultUtils.issue_link(v) }
26
+ matching_links(metadata, :issue)
31
27
  end
32
28
 
33
29
  # Get severity
@@ -50,6 +46,20 @@ module AllureRspec
50
46
 
51
47
  private
52
48
 
49
+ # @param [Hash] metadata
50
+ # @param [Symbol] type
51
+ # @return [Array<Allure::Link>]
52
+ def matching_links(metadata, type)
53
+ unless AllureRspec.configuration.public_send("link_#{type}_pattern") &&
54
+ metadata.keys.any? { |k| __send__("#{type}?", k) }
55
+ return []
56
+ end
57
+
58
+ metadata
59
+ .select { |k| __send__("#{type}?", k) }.values
60
+ .map { |v| Allure::ResultUtils.public_send("#{type}_link", v) }
61
+ end
62
+
53
63
  # Does key match custom allure label
54
64
  # @param [Symbol] key
55
65
  # @return [boolean]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.3
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-01-07 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allure-ruby-commons
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.13.3
19
+ version: 2.13.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.13.3
26
+ version: 2.13.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-core
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ruby2_keywords
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.2
41
55
  description: Cucumber adaptor to generate rich allure test reports
42
56
  email: andrejs.cunskis@gmail.com
43
57
  executables: []
@@ -46,6 +60,7 @@ extra_rdoc_files: []
46
60
  files:
47
61
  - README.md
48
62
  - lib/allure-rspec.rb
63
+ - lib/allure_rspec/config.rb
49
64
  - lib/allure_rspec/formatter.rb
50
65
  - lib/allure_rspec/rspec_model.rb
51
66
  - lib/allure_rspec/tag_parser.rb
@@ -73,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
88
  - !ruby/object:Gem::Version
74
89
  version: '0'
75
90
  requirements: []
76
- rubygems_version: 3.0.3
91
+ rubygems_version: 3.1.2
77
92
  signing_key:
78
93
  specification_version: 4
79
94
  summary: Allure rspec ruby adaptor