allure-rspec 2.13.4 → 2.13.6.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: afcc5a2dfc396dc25bdf88815e525a64150e6929b6888b7d416ecbcb458abf8e
4
- data.tar.gz: 4566d418f42a82c7cbdb03f08f9812afc468ff2cf9866dafeb42e37e8e0031a3
3
+ metadata.gz: 0f26f885d375599cb9e3903ca34bf49e6339a5ec1554d804796706679178b62d
4
+ data.tar.gz: aa23237291bd90b696d814797d353d8bf61e7b16769a61235d020b6ffa278317
5
5
  SHA512:
6
- metadata.gz: 21da1ae0df8fc7c5b1baa1c7fa561366f24cb77f0de0a79fe31389ce79d263b9de6ba23ec864fe66f6f32383a0d5080890794085d2f3c95632be37fce615b8ee
7
- data.tar.gz: c46c715f9a11543e910cea93a8bc087aa02daab854ca8baa2e8d993496ce5bed06690957e43cb5e9c50a317b6db0dacd6f453c69d9ff17d6aa0ba756df11e654
6
+ metadata.gz: 9009680c99face3c98206ecb186e97f17f3ff1b90f2e2acda6010e8d982783981b147235babe4dc3f9cba3bd7185ab1380f0c6fd66b96c36951fe2b6b5b99791
7
+ data.tar.gz: 78373bf141e0ff17ab36f78d82438180b486d067775606e511e798c11aac5897dca94f935dacb97a4f8fe3bf66d108eb98c305a82e917eaf24a8fd2b9a9ab2b6
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
@@ -6,7 +6,9 @@ require "rspec/core/formatters/base_formatter"
6
6
 
7
7
  require_relative "rspec_model"
8
8
 
9
+ # Main allure-rspec module
9
10
  module AllureRspec
11
+ # Main rspec formatter class translating rspec events to allure lifecycle
10
12
  class RSpecFormatter < RSpec::Core::Formatters::BaseFormatter
11
13
  include AllureRspecModel
12
14
 
@@ -36,9 +38,10 @@ module AllureRspec
36
38
  # @param [RSpec::Core::Notifications::GroupNotification] example_group_notification
37
39
  # @return [void]
38
40
  def example_group_started(example_group_notification)
39
- lifecycle.start_test_container(
40
- Allure::TestResultContainer.new(name: example_group_notification.group.description),
41
- )
41
+ description = example_group_notification.group.description.yield_self do |desc|
42
+ desc.empty? ? "Anonymous" : desc
43
+ end
44
+ lifecycle.start_test_container(Allure::TestResultContainer.new(name: description))
42
45
  end
43
46
 
44
47
  # Starts example
@@ -57,7 +60,7 @@ module AllureRspec
57
60
  end
58
61
 
59
62
  # Starts example group
60
- # @param [RSpec::Core::Notifications::GroupNotification] example_group_notification
63
+ # @param [RSpec::Core::Notifications::GroupNotification] _example_group_notification
61
64
  # @return [void]
62
65
  def example_group_finished(_example_group_notification)
63
66
  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
 
@@ -66,28 +67,30 @@ module AllureRspec
66
67
  # @param [RSpec::Core::Example] example
67
68
  # @return [Array<Allure::Label>]
68
69
  def labels(example)
69
- [].tap do |labels|
70
- labels << Allure::ResultUtils.framework_label("rspec")
71
- labels << Allure::ResultUtils.feature_label(example.example_group.description)
72
- labels << Allure::ResultUtils.package_label(Pathname.new(strip_relative(example.file_path)).parent.to_s)
73
- labels << Allure::ResultUtils.story_label(example.description)
74
- labels << Allure::ResultUtils.test_class_label(File.basename(example.file_path, ".rb"))
75
- labels << severity(example.metadata)
76
- labels.push(*tag_labels(example.metadata))
77
- labels.push(*suite_labels(example.example_group))
78
- end
70
+ labels = []
71
+ labels << Allure::ResultUtils.framework_label("rspec")
72
+ labels << Allure::ResultUtils.feature_label(example.example_group.description)
73
+ labels << Allure::ResultUtils.package_label(Pathname.new(strip_relative(example.file_path)).parent.to_s)
74
+ labels << Allure::ResultUtils.story_label(example.description)
75
+ labels << Allure::ResultUtils.test_class_label(File.basename(example.file_path, ".rb"))
76
+ labels << severity(example.metadata)
77
+ labels.push(*tag_labels(example.metadata))
78
+ labels.push(*suite_labels(example.example_group))
79
+
80
+ labels
79
81
  end
80
82
 
81
83
  # Add suite labels
82
84
  # @param [RSpec::Core::ExampleGroup] example_group
83
85
  # @return [Array<Allure::Label>]
84
86
  def suite_labels(example_group)
85
- [].tap do |labels|
86
- parents = example_group.parent_groups.map(&:description)
87
- labels << Allure::ResultUtils.suite_label(suite(parents))
88
- labels << Allure::ResultUtils.parent_suite_label(parent_suite(parents))
89
- labels << Allure::ResultUtils.sub_suite_label(sub_suites(parents))
90
- end
87
+ parents = example_group.parent_groups.map { |group| group.description.empty? ? "Anonymous" : group.description }
88
+ labels = []
89
+ labels << Allure::ResultUtils.suite_label(suite(parents))
90
+ labels << Allure::ResultUtils.parent_suite_label(parent_suite(parents)) if parent_suite(parents)
91
+ labels << Allure::ResultUtils.sub_suite_label(sub_suites(parents)) if sub_suites(parents)
92
+
93
+ labels
91
94
  end
92
95
 
93
96
  # @param [Array<String>] parents
@@ -50,7 +50,8 @@ module AllureRspec
50
50
  # @param [Symbol] type
51
51
  # @return [Array<Allure::Link>]
52
52
  def matching_links(metadata, type)
53
- unless Allure::Config.public_send("link_#{type}_pattern") && metadata.keys.any? { |k| __send__("#{type}?", k) }
53
+ unless AllureRspec.configuration.public_send("link_#{type}_pattern") &&
54
+ metadata.keys.any? { |k| __send__("#{type}?", k) }
54
55
  return []
55
56
  end
56
57
 
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.4
4
+ version: 2.13.6.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: 2020-02-25 00:00:00.000000000 Z
11
+ date: 2020-06-27 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.4
19
+ version: 2.13.6.1
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.4
26
+ version: 2.13.6.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-core
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +60,7 @@ extra_rdoc_files: []
60
60
  files:
61
61
  - README.md
62
62
  - lib/allure-rspec.rb
63
+ - lib/allure_rspec/config.rb
63
64
  - lib/allure_rspec/formatter.rb
64
65
  - lib/allure_rspec/rspec_model.rb
65
66
  - lib/allure_rspec/tag_parser.rb