allure-rspec 0.7.7 → 2.13.4

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
- SHA1:
3
- metadata.gz: baa2c3882850c2541da13284782c5d3a25ae2bc2
4
- data.tar.gz: 1db3ef04498df8261182f90ba331f9f38991e8ad
2
+ SHA256:
3
+ metadata.gz: afcc5a2dfc396dc25bdf88815e525a64150e6929b6888b7d416ecbcb458abf8e
4
+ data.tar.gz: 4566d418f42a82c7cbdb03f08f9812afc468ff2cf9866dafeb42e37e8e0031a3
5
5
  SHA512:
6
- metadata.gz: 1ca714bc7f10abe80311123e3743e163f8de17ed0a27ddc44f4119dcfb95979224498b0b02775b8f3f425b19d11329bc2eea569b316202ed64e9c37cc38d6201
7
- data.tar.gz: f2e0830b214d64872170b557757f3a558fa5dddb781173d151aeb5158f46d7d8c794c3751dee605ad4e0ef225778179b76ffa81f3374632d84d6a227b1bb875a
6
+ metadata.gz: 21da1ae0df8fc7c5b1baa1c7fa561366f24cb77f0de0a79fe31389ce79d263b9de6ba23ec864fe66f6f32383a0d5080890794085d2f3c95632be37fce615b8ee
7
+ data.tar.gz: c46c715f9a11543e910cea93a8bc087aa02daab854ca8baa2e8d993496ce5bed06690957e43cb5e9c50a317b6db0dacd6f453c69d9ff17d6aa0ba756df11e654
data/README.md CHANGED
@@ -1,74 +1,140 @@
1
- # Allure RSpec Adaptor
1
+ # allure-rspec
2
+ [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/allure-rspec)
2
3
 
3
- [![Gem Version](https://badge.fury.io/rb/allure-rspec.svg)](http://badge.fury.io/rb/allure-rspec)
4
+ Allure adapter for [rspec](https://rspec.info/) testing framework
4
5
 
5
- Adaptor to use the Allure framework along with the RSpec. See [an example](https://github.com/allure-examples/allure-rspec-example) project to take a quick tour.
6
+ ## Installation
6
7
 
7
- ## What's new
8
+ Add it to gemfile:
8
9
 
9
- See the [releases](https://github.com/allure-framework/allure-rspec/releases) tab.
10
+ ```ruby
11
+ gem 'allure-rspec'
12
+ ```
13
+
14
+ Require in `spec_helper` or any other setup file:
15
+
16
+ ```ruby
17
+ require `allure-rspec`
18
+ ```
19
+
20
+ ## Configuration
10
21
 
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)
11
23
 
12
- ## Setup
24
+ ## Usage
13
25
 
14
- Add the dependency to your Gemfile. Choose the version carefully:
15
- * 0.5.x - for RSpec2.
16
- * <= 0.6.7 - for RSpec < 3.2.
17
- * >= 0.6.9 - for RSpec >= 3.2.
26
+ Via commandline, simply add:
27
+
28
+ ```bash
29
+ --format AllureRspecFormatter
30
+ ```
31
+
32
+ RSpec configuration:
18
33
 
19
34
  ```ruby
20
- gem 'allure-rspec'
35
+ RSpec.configure do |c|
36
+ c.formatter = AllureRspecFormatter
37
+ end
21
38
  ```
22
39
 
23
- And then include it in your spec_helper.rb:
40
+ ### Adding tms links
41
+
42
+ Configure tms link pattern:
24
43
 
25
44
  ```ruby
26
- RSpec.configure do |c|
27
- c.include AllureRSpec::Adaptor
28
- end
45
+ Allure.configure do |c|
46
+ c.link_tms_pattern = "http://www.jira.com/browse/{}"
47
+ end
29
48
  ```
30
49
 
31
- ## Advanced options
50
+ Add tag to rspec test:
32
51
 
33
- You can specify the directory where the Allure test results will appear. By default it would be 'gen/allure-results'
34
- within your current directory.
52
+ ```ruby
53
+ it "some test case", tms: "QA-123" do
54
+ # test
55
+ end
56
+ ```
57
+
58
+ It's possible to add multiple tms links using `tms_` pattern:
35
59
 
36
60
  ```ruby
37
- AllureRSpec.configure do |c|
38
- c.output_dir = "/whatever/you/like" # default: gen/allure-results
39
- c.clean_dir = false # clean the output directory first? (default: true)
40
- c.logging_level = Logger::DEBUG # logging level (default: DEBUG)
41
- end
61
+ it "some test case", tms_1: "QA-123", tms_2: "QA-124" do
62
+ # test
63
+ end
42
64
  ```
43
65
 
44
- ## Usage examples
66
+ ### Adding issue links
67
+
68
+ Configure issue link pattern:
45
69
 
46
70
  ```ruby
47
- describe MySpec, :feature => "Some feature", :severity => :normal do
71
+ Allure.configure do |c|
72
+ c.link_issue_pattern = "http://www.jira.com/browse/{}"
73
+ end
74
+ ```
48
75
 
49
- before(:step) do |s|
50
- puts "Before step #{s.current_step}"
51
- end
76
+ Add tag to rspec test:
52
77
 
53
- it "should be critical", :story => "First story", :severity => :critical, :testId => 99 do
54
- "string".should == "string"
55
- end
78
+ ```ruby
79
+ it "some test case", issue: "QA-123" do
80
+ # test
81
+ end
82
+ ```
56
83
 
57
- it "should be steps enabled", :story => ["First story", "Second story"], :testId => 31 do |e|
84
+ It's possible to add multiple tms links using `issue_` pattern:
58
85
 
59
- e.step "step1" do |s|
60
- s.attach_file "screenshot1", take_screenshot_as_file
61
- end
86
+ ```ruby
87
+ it "some test case", issue_1: "QA-123", issue_2: "QA-124" do
88
+ # test
89
+ end
90
+ ```
91
+
92
+ ### Adding custom severity and status details
62
93
 
63
- e.step "step2" do
64
- 5.should be > 0
65
- end
94
+ Test severity (`normal` by default) can be changed via `severity` tag:
95
+
96
+ ```ruby
97
+ it "some test case", severity: :critical do
98
+ # test
99
+ end
100
+ ```
101
+
102
+ Custom status details can be set via `muted`, `known`, `flaky` tags:
103
+
104
+ ```ruby
105
+ it "some test case", flaky: true, muted: false, known: true do
106
+ # test
107
+ end
108
+ ```
66
109
 
67
- e.step "step3" do
68
- 0.should == 0
69
- end
110
+ ### Adding additional labels to allure test case
70
111
 
71
- e.attach_file "screenshot2", take_screenshot_as_file
112
+ Additional labels can be added using `allure_` pattern:
113
+
114
+ ```ruby
115
+ it "some test case", allure_1: "visual_test", allure_2: "core_functionality" do
116
+ # test
117
+ end
118
+ ```
119
+
120
+ ### Custom actions
121
+
122
+ Rspec example object has access to [Allure](https://www.rubydoc.info/github/allure-framework/allure-ruby/Allure) helper methods.
123
+ It can be used to add or run steps, add attachments, modify test case etc.
124
+
125
+ ```ruby
126
+ it "some test case" do |e|
127
+ e.run_step("my custom step") do
128
+ # some action
72
129
  end
130
+ e.add_attachment(name: "attachment", source: "Some string", type: Allure::ContentType::TXT)
73
131
  end
74
132
  ```
133
+
134
+ ### Example project
135
+
136
+ [RSpec Example](https://github.com/allure-examples/allure-rspec-example)
137
+
138
+ ## HTML report generation
139
+
140
+ Report is generated using allure commandline tool. [Allure wiki](https://docs.qameta.io/allure/#_reporting).
@@ -1,56 +1,8 @@
1
- require 'allure-ruby-adaptor-api'
2
- require 'allure-rspec/version'
3
- require 'allure-rspec/formatter'
4
- require 'allure-rspec/adaptor'
5
- require 'allure-rspec/dsl'
6
- require 'allure-rspec/hooks'
1
+ # rubocop:disable Naming/FileName
2
+ # frozen_string_literal: true
7
3
 
8
- module AllureRSpec
9
- module Config
10
- class << self
11
- attr_accessor :output_dir
12
- attr_accessor :clean_dir
13
- attr_accessor :logging_level
4
+ require "allure-ruby-commons"
5
+ require "allure_rspec/formatter"
14
6
 
15
- DEFAULT_OUTPUT_DIR = 'gen/allure-results'
16
- DEFAULT_LOGGING_LEVEL = Logger::DEBUG
17
-
18
- def output_dir
19
- @output_dir || DEFAULT_OUTPUT_DIR
20
- end
21
-
22
- def clean_dir?
23
- @clean_dir.nil? ? true : @clean_dir
24
- end
25
-
26
- def logging_level
27
- @logging_level || DEFAULT_LOGGING_LEVEL
28
- end
29
- end
30
- end
31
-
32
- class Context
33
- attr_accessor :rspec
34
-
35
- def rspec
36
- @rspec
37
- end
38
- end
39
-
40
- class << self
41
- def context
42
- @context ||= Context.new
43
- end
44
- end
45
-
46
- class << self
47
- def configure(&block)
48
- yield Config
49
- AllureRubyAdaptorApi.configure { |c|
50
- c.output_dir = Config.output_dir
51
- c.logging_level = Config.logging_level
52
- }
53
- end
54
- end
55
-
56
- end
7
+ AllureRspecFormatter = AllureRspec::RSpecFormatter
8
+ # rubocop:enable Naming/FileName
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ruby2_keywords"
4
+ require "rspec/core"
5
+ require "rspec/core/formatters/base_formatter"
6
+
7
+ require_relative "rspec_model"
8
+
9
+ module AllureRspec
10
+ class RSpecFormatter < RSpec::Core::Formatters::BaseFormatter
11
+ include AllureRspecModel
12
+
13
+ RSpec::Core::Formatters.register(
14
+ self,
15
+ :start,
16
+ :example_group_started,
17
+ :example_group_finished,
18
+ :example_started,
19
+ :example_finished,
20
+ )
21
+
22
+ RSpec::Core::Example.class_eval do
23
+ Allure.singleton_methods.each do |method|
24
+ ruby2_keywords define_method(method) { |*args, &block| Allure.__send__(method, *args, &block) }
25
+ end
26
+ end
27
+
28
+ # Start test run
29
+ # @param [RSpec::Core::Notifications::StartNotification] _start_notification
30
+ # @return [void]
31
+ def start(_start_notification)
32
+ lifecycle.clean_results_dir
33
+ end
34
+
35
+ # Starts example group
36
+ # @param [RSpec::Core::Notifications::GroupNotification] example_group_notification
37
+ # @return [void]
38
+ def example_group_started(example_group_notification)
39
+ lifecycle.start_test_container(
40
+ Allure::TestResultContainer.new(name: example_group_notification.group.description),
41
+ )
42
+ end
43
+
44
+ # Starts example
45
+ # @param [RSpec::Core::Notifications::ExampleNotification] example_notification
46
+ # @return [void]
47
+ def example_started(example_notification)
48
+ lifecycle.start_test_case(test_result(example_notification.example))
49
+ end
50
+
51
+ # Finishes example
52
+ # @param [RSpec::Core::Notifications::ExampleNotification] example_notification
53
+ # @return [void]
54
+ def example_finished(example_notification)
55
+ lifecycle.update_test_case(&update_test_proc(example_notification.example.execution_result))
56
+ lifecycle.stop_test_case
57
+ end
58
+
59
+ # Starts example group
60
+ # @param [RSpec::Core::Notifications::GroupNotification] example_group_notification
61
+ # @return [void]
62
+ def example_group_finished(_example_group_notification)
63
+ lifecycle.stop_test_container
64
+ end
65
+
66
+ private
67
+
68
+ # Get thread specific lifecycle
69
+ # @return [Allure::AllureLifecycle]
70
+ def lifecycle
71
+ Allure.lifecycle
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest"
4
+ require "pathname"
5
+
6
+ require_relative "tag_parser"
7
+
8
+ module AllureRspec
9
+ module AllureRspecModel
10
+ include TagParser
11
+
12
+ # @return [Hash] allure statuses mapping
13
+ ALLURE_STATUS ||= {
14
+ failed: Allure::Status::FAILED,
15
+ pending: Allure::Status::SKIPPED,
16
+ passed: Allure::Status::PASSED,
17
+ }.freeze
18
+
19
+ # Transform example to <Allure::TestResult>
20
+ # @param [RSpec::Core::Example] example
21
+ # @return [Allure::TestResult]
22
+ def test_result(example)
23
+ Allure::TestResult.new(
24
+ name: example.description,
25
+ description: "Location - #{strip_relative(example.location)}",
26
+ description_html: "Location - #{strip_relative(example.location)}",
27
+ history_id: Digest::MD5.hexdigest(example.id),
28
+ full_name: example.full_description,
29
+ labels: labels(example),
30
+ links: links(example),
31
+ status_details: Allure::StatusDetails.new(**status_detail_tags(example.metadata)),
32
+ )
33
+ end
34
+
35
+ # Update test status on finish
36
+ # @param [RSpec::Core::Example::ExecutionResult] result
37
+ # @return [Proc]
38
+ def update_test_proc(result)
39
+ Allure::ResultUtils.status_details(result.exception).yield_self do |status_detail|
40
+ proc do |test_case|
41
+ test_case.stage = Allure::Stage::FINISHED
42
+ test_case.status = status(result)
43
+ test_case.status_details.message = status_detail.message
44
+ test_case.status_details.trace = status_detail.trace
45
+ end
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ # @param [RSpec::Core::Example] example
52
+ # @return [Array<Allure::Label>]
53
+ def links(example)
54
+ tms_links(example.metadata) + issue_links(example.metadata)
55
+ end
56
+
57
+ # Get allure status from result
58
+ # @param [RSpec::Core::Example::ExecutionResult] result
59
+ # @return [Symbol]
60
+ def status(result)
61
+ return Allure::ResultUtils.status(result.exception) if result.status == :failed
62
+
63
+ ALLURE_STATUS[result.status]
64
+ end
65
+
66
+ # @param [RSpec::Core::Example] example
67
+ # @return [Array<Allure::Label>]
68
+ 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
79
+ end
80
+
81
+ # Add suite labels
82
+ # @param [RSpec::Core::ExampleGroup] example_group
83
+ # @return [Array<Allure::Label>]
84
+ 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
91
+ end
92
+
93
+ # @param [Array<String>] parents
94
+ # @return [String]
95
+ def suite(parents)
96
+ parents.length == 1 ? parents.last : parents[-2]
97
+ end
98
+
99
+ # @param [Array<String>] parents
100
+ # @return [String]
101
+ def parent_suite(parents)
102
+ parents.length > 1 ? parents.last : nil
103
+ end
104
+
105
+ # @param [Array<String>] parents
106
+ # @return [String]
107
+ def sub_suites(parents)
108
+ parents.length > 2 ? parents[0..-3].join(" > ") : nil
109
+ end
110
+
111
+ # Strip relative ./ form path
112
+ # @param [String] path
113
+ # @return [String]
114
+ def strip_relative(path)
115
+ path.gsub("./", "")
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AllureRspec
4
+ # RSpec custom tag parser
5
+ module TagParser
6
+ # Get custom labels
7
+ # @param [Hash] metadata
8
+ # @return [Array<Allure::Label>]
9
+ def tag_labels(metadata)
10
+ return [] unless metadata.keys.any? { |k| allure?(k) }
11
+
12
+ metadata.select { |k| allure?(k) }.values.map { |v| Allure::ResultUtils.tag_label(v) }
13
+ end
14
+
15
+ # Get tms links
16
+ # @param [Hash] metadata
17
+ # @return [Array<Allure::Link>]
18
+ def tms_links(metadata)
19
+ matching_links(metadata, :tms)
20
+ end
21
+
22
+ # Get issue links
23
+ # @param [Hash] metadata
24
+ # @return [Array<Allure::Link>]
25
+ def issue_links(metadata)
26
+ matching_links(metadata, :issue)
27
+ end
28
+
29
+ # Get severity
30
+ # @param [Hash] metadata
31
+ # @return [String]
32
+ def severity(metadata)
33
+ Allure::ResultUtils.severity_label(metadata[:severity] || "normal")
34
+ end
35
+
36
+ # Get status details
37
+ # @param [Hash] metadata
38
+ # @return [Hash<Symbol, Boolean>]
39
+ def status_detail_tags(metadata)
40
+ {
41
+ flaky: !!metadata[:flaky],
42
+ muted: !!metadata[:muted],
43
+ known: !!metadata[:known],
44
+ }
45
+ end
46
+
47
+ private
48
+
49
+ # @param [Hash] metadata
50
+ # @param [Symbol] type
51
+ # @return [Array<Allure::Link>]
52
+ def matching_links(metadata, type)
53
+ unless Allure::Config.public_send("link_#{type}_pattern") && metadata.keys.any? { |k| __send__("#{type}?", k) }
54
+ return []
55
+ end
56
+
57
+ metadata
58
+ .select { |k| __send__("#{type}?", k) }.values
59
+ .map { |v| Allure::ResultUtils.public_send("#{type}_link", v) }
60
+ end
61
+
62
+ # Does key match custom allure label
63
+ # @param [Symbol] key
64
+ # @return [boolean]
65
+ def allure?(key)
66
+ key.to_s.match?(/allure(_\d+)?/i)
67
+ end
68
+
69
+ # Does key match tms pattern
70
+ # @param [Symbol] key
71
+ # @return [boolean]
72
+ def tms?(key)
73
+ key.to_s.match?(/tms(_\d+)?/i)
74
+ end
75
+
76
+ # Does key match issue pattern
77
+ # @param [Symbol] key
78
+ # @return [boolean]
79
+ def issue?(key)
80
+ key.to_s.match?(/issue(_\d+)?/i)
81
+ end
82
+ end
83
+ end
metadata CHANGED
@@ -1,101 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 2.13.4
5
5
  platform: ruby
6
6
  authors:
7
- - Ilya Sadykov
7
+ - Andrejs Cunskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-03 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.2'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '3.2'
27
- - !ruby/object:Gem::Dependency
28
- name: allure-ruby-adaptor-api
14
+ name: allure-ruby-commons
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - '='
32
18
  - !ruby/object:Gem::Version
33
- version: 0.6.10
19
+ version: 2.13.4
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - '='
39
25
  - !ruby/object:Gem::Version
40
- version: 0.6.10
26
+ version: 2.13.4
41
27
  - !ruby/object:Gem::Dependency
42
- name: bundler
28
+ name: rspec-core
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ">="
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
33
+ version: '3.8'
34
+ type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ">="
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: '3.8'
55
41
  - !ruby/object:Gem::Dependency
56
- name: rake
42
+ name: ruby2_keywords
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ">="
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
47
+ version: 0.0.2
48
+ type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ">="
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '0'
69
- description: Adaptor to use Allure framework along with the RSpec 2
70
- email:
71
- - smecsia@yandex-team.ru
54
+ version: 0.0.2
55
+ description: Cucumber adaptor to generate rich allure test reports
56
+ email: andrejs.cunskis@gmail.com
72
57
  executables: []
73
58
  extensions: []
74
59
  extra_rdoc_files: []
75
60
  files:
76
- - ".gitignore"
77
- - Gemfile
78
- - Gemfile.lock
79
61
  - README.md
80
- - allure-rspec.gemspec
81
62
  - lib/allure-rspec.rb
82
- - lib/allure-rspec/adaptor.rb
83
- - lib/allure-rspec/dsl.rb
84
- - lib/allure-rspec/formatter.rb
85
- - lib/allure-rspec/hooks.rb
86
- - lib/allure-rspec/version.rb
87
- - logo.png
88
- - spec/another_spec.rb
89
- - spec/extend_steps_spec.rb
90
- - spec/hooks_spec.rb
91
- - spec/issue51_spec.rb
92
- - spec/nometavalue_spec.rb
93
- - spec/shared_example_spec.rb
94
- - spec/spec_helper.rb
95
- homepage: http://allure.qatools.ru
63
+ - lib/allure_rspec/formatter.rb
64
+ - lib/allure_rspec/rspec_model.rb
65
+ - lib/allure_rspec/tag_parser.rb
66
+ homepage: https://github.com/allure-framework/allure-ruby/tree/master/allure-rspec
96
67
  licenses:
97
- - Apache2
98
- metadata: {}
68
+ - Apache-2.0
69
+ metadata:
70
+ bug_tracker_uri: https://github.com/allure-framework/allure-ruby/issues
71
+ changelog_uri: https://github.com/allure-framework/allure-ruby/releases
72
+ documentation_uri: https://github.com/allure-framework/allure-ruby/blob/master/allure-rspec/README.md
73
+ source_code_uri: https://github.com/allure-framework/allure-ruby/tree/master/allure-rspec
74
+ wiki_uri: https://github.com/allure-framework/allure-ruby/wiki
99
75
  post_install_message:
100
76
  rdoc_options: []
101
77
  require_paths:
@@ -104,16 +80,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
80
  requirements:
105
81
  - - ">="
106
82
  - !ruby/object:Gem::Version
107
- version: '0'
83
+ version: 2.5.0
108
84
  required_rubygems_version: !ruby/object:Gem::Requirement
109
85
  requirements:
110
86
  - - ">="
111
87
  - !ruby/object:Gem::Version
112
88
  version: '0'
113
89
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.4.6
90
+ rubygems_version: 3.1.2
116
91
  signing_key:
117
92
  specification_version: 4
118
- summary: allure-rspec-0.7.7
93
+ summary: Allure rspec ruby adaptor
119
94
  test_files: []
data/.gitignore DELETED
@@ -1,15 +0,0 @@
1
- *.class
2
-
3
- # Package Files #
4
- *.jar
5
- *.war
6
- *.ear
7
- *.gem
8
-
9
- allure-report
10
- target
11
- allure
12
- .idea
13
- *.iml
14
- *.ipr
15
- *.iws
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
@@ -1,49 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- allure-rspec (0.7.7)
5
- allure-ruby-adaptor-api (= 0.6.10)
6
- rspec (~> 3.2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- allure-ruby-adaptor-api (0.6.10)
12
- mimemagic
13
- nokogiri (~> 1.6.0)
14
- uuid
15
- diff-lcs (1.2.5)
16
- macaddr (1.7.1)
17
- systemu (~> 2.6.2)
18
- mimemagic (0.3.1)
19
- mini_portile2 (2.0.0)
20
- nokogiri (1.6.7.2)
21
- mini_portile2 (~> 2.0.0.rc2)
22
- rake (10.4.2)
23
- rspec (3.4.0)
24
- rspec-core (~> 3.4.0)
25
- rspec-expectations (~> 3.4.0)
26
- rspec-mocks (~> 3.4.0)
27
- rspec-core (3.4.2)
28
- rspec-support (~> 3.4.0)
29
- rspec-expectations (3.4.0)
30
- diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.4.0)
32
- rspec-mocks (3.4.1)
33
- diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.4.0)
35
- rspec-support (3.4.1)
36
- systemu (2.6.5)
37
- uuid (2.3.8)
38
- macaddr (~> 1.0)
39
-
40
- PLATFORMS
41
- ruby
42
-
43
- DEPENDENCIES
44
- allure-rspec!
45
- bundler
46
- rake
47
-
48
- BUNDLED WITH
49
- 1.10.5
@@ -1,26 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
- require "allure-rspec/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'allure-rspec'
7
- s.version = AllureRSpec::Version::STRING
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['Ilya Sadykov']
10
- s.email = ['smecsia@yandex-team.ru']
11
- s.description = %q{Adaptor to use Allure framework along with the RSpec 2}
12
- s.summary = "allure-rspec-#{AllureRSpec::Version::STRING}"
13
- s.homepage = 'http://allure.qatools.ru'
14
- s.license = 'Apache2'
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ['lib']
20
-
21
- s.add_dependency 'rspec', '~> 3.2'
22
- s.add_dependency 'allure-ruby-adaptor-api', '0.6.10'
23
-
24
- s.add_development_dependency 'bundler'
25
- s.add_development_dependency 'rake'
26
- end
@@ -1,15 +0,0 @@
1
- module AllureRSpec
2
- module Adaptor
3
- def self.included(base)
4
- AllureRSpec.context.rspec = base
5
- base.send :include, AllureRSpec::DSL
6
- if RSpec::Core::Formatters::Loader.formatters.keys.find_all { |f| f == AllureRSpec::Formatter }.empty?
7
- RSpec::Core::Formatters.register AllureRSpec::Formatter, *AllureRSpec::Formatter::NOTIFICATIONS
8
- RSpec.configuration.add_formatter(AllureRSpec::Formatter)
9
- end
10
- RSpec::Core::ExampleGroup.send :include, AllureRSpec::Hooks
11
- RSpec::Core::Example.send :include, AllureRSpec::DSL::Example
12
- end
13
- end
14
- end
15
-
@@ -1,61 +0,0 @@
1
- require 'digest'
2
- require 'mimemagic'
3
- module AllureRSpec
4
- module DSL
5
- module Example
6
-
7
- def current_step
8
- if defined? @@__current_step
9
- @@__current_step
10
- else
11
- nil
12
- end
13
- end
14
-
15
- def step(step, &block)
16
- suite = __description(metadata[:example_group])
17
- test = __description(metadata)
18
- begin
19
- AllureRubyAdaptorApi::Builder.start_step(suite, test, step)
20
- __with_step step, &block
21
- AllureRubyAdaptorApi::Builder.stop_step(suite, test, step)
22
- rescue Exception => e
23
- AllureRubyAdaptorApi::Builder.stop_step(suite, test, step, :failed)
24
- raise e
25
- end
26
- end
27
-
28
-
29
- def attach_file(title, file, opts = {})
30
- suite = __description(metadata[:example_group])
31
- test = __description(metadata)
32
- step = current_step
33
- AllureRubyAdaptorApi::Builder.add_attachment suite, test, opts.merge(:title => title, :file => file, :step => step)
34
- end
35
-
36
- private
37
-
38
- def __description(data)
39
- data[:full_description] || data[:description]
40
- end
41
-
42
- def __mutex
43
- @@__mutex ||= Mutex.new
44
- end
45
-
46
- def __with_step(step, &block)
47
- __mutex.synchronize do
48
- begin
49
- @@__current_step = step
50
- AllureRSpec.context.rspec.hooks.send :run, :before, :step, self
51
- yield self
52
- ensure
53
- AllureRSpec.context.rspec.hooks.send :run, :after, :step, self
54
- @@__current_step = nil
55
- end
56
- end
57
- end
58
- end
59
- end
60
- end
61
-
@@ -1,117 +0,0 @@
1
- require 'rspec/core' unless defined?(RSpec::Core)
2
- require 'rspec/core/formatters/base_formatter' unless defined?(RSpec::Core::Formatters::BaseFormatter)
3
- require 'fileutils'
4
-
5
- module AllureRSpec
6
-
7
- class Formatter < RSpec::Core::Formatters::BaseFormatter
8
-
9
- NOTIFICATIONS = [:example_group_started, :example_group_finished, :example_started,
10
- :example_failed, :example_passed, :example_pending, :start, :stop]
11
- ALLOWED_LABELS = [:feature, :story, :severity, :language, :framework, :issue, :testId, :host, :thread]
12
-
13
- def example_failed(notification)
14
- res = notification.example.execution_result
15
- status = res.exception.is_a?(RSpec::Expectations::ExpectationNotMetError) ? :failed : :broken
16
- stop_test(notification.example, :exception => res.exception, :status => status)
17
- end
18
-
19
- def example_group_finished(notification)
20
- AllureRubyAdaptorApi::Builder.stop_suite(description(notification.group).to_s)
21
- end
22
-
23
- def example_group_started(notification)
24
- AllureRubyAdaptorApi::Builder.start_suite(description(notification.group).to_s, labels(notification))
25
- end
26
-
27
- def example_passed(notification)
28
- stop_test(notification.example)
29
- end
30
-
31
- def example_pending(notification)
32
- stop_test(notification.example)
33
- end
34
-
35
- def example_started(notification)
36
- suite = description(notification.example.example_group).to_s
37
- test = description(notification.example).to_s
38
- AllureRubyAdaptorApi::Builder.start_test(suite, test, labels(notification))
39
- end
40
-
41
- def start(example_count)
42
- dir = Pathname.new(AllureRSpec::Config.output_dir)
43
- if AllureRSpec::Config.clean_dir?
44
- puts "Cleaning output directory '#{dir}'..."
45
- FileUtils.rm_rf(dir)
46
- end
47
- FileUtils.mkdir_p(dir)
48
- end
49
-
50
- def stop(notify)
51
- AllureRubyAdaptorApi::Builder.build!
52
- end
53
-
54
- private
55
-
56
- def description(data, attr = :full_description)
57
- ((((data.respond_to?(attr)) ?
58
- data.send(attr) : data.metadata[attr]) ||
59
- description(data, :description)) || '').strip
60
- end
61
-
62
- def stop_test(example, opts = {})
63
- res = example.execution_result
64
- AllureRubyAdaptorApi::Builder.stop_test(
65
- description(example.example_group).to_s,
66
- (example.metadata[:description_args].size== 0) ? description(example.example_group) : description(example).to_s,
67
- {
68
- :status => res.status,
69
- :finished_at => res.finished_at,
70
- :started_at => res.started_at
71
- }.merge(opts)
72
- )
73
- end
74
-
75
- def metadata(example_or_group)
76
- group?(example_or_group) ?
77
- example_or_group.group.metadata :
78
- example_or_group.example.metadata
79
- end
80
-
81
- def group?(example_or_group)
82
- (example_or_group.respond_to? :group)
83
- end
84
-
85
- def labels(example_or_group)
86
- labels = ALLOWED_LABELS.map { |label| [label, metadata(example_or_group)[label]] }.
87
- find_all { |value| !value[1].nil? }.
88
- inject({}) { |res, value| res.merge(value[0] => value[1]) }
89
- detect_feature_story(labels, example_or_group)
90
- labels
91
- end
92
-
93
- def method_or_key(metadata, key)
94
- metadata.respond_to?(key) ? metadata.send(key) : metadata[key]
95
- end
96
-
97
- def detect_feature_story(labels, example_or_group)
98
- metadata = metadata(example_or_group)
99
- is_group = group?(example_or_group)
100
- parent = (method_or_key(metadata, :parent_example_group))
101
- if labels[:feature] === true
102
- description = (!is_group && parent) ? method_or_key(parent, :description) : method_or_key(metadata, :description)
103
- labels[:feature] = description
104
- if labels[:story] === true
105
- if parent
106
- grandparent = parent && method_or_key(parent, :parent_example_group)
107
- labels[:feature] = (!is_group && grandparent) ? method_or_key(grandparent, :description) :
108
- method_or_key(parent, :description)
109
- end
110
- labels[:story] = description
111
- end
112
- end
113
- labels
114
- end
115
-
116
- end
117
- end
@@ -1,86 +0,0 @@
1
- module AllureRSpec
2
- module Hooks
3
-
4
- def self.included(cls)
5
- cls.extend OverrideHooksMethods
6
- end
7
-
8
- module OverrideHooksMethods
9
- include RSpec::Core::Hooks
10
-
11
- alias_method :old_hooks, :hooks
12
-
13
- def hooks
14
- @__hooks ||= OverridenHookCollections.new(old_hooks)
15
- end
16
-
17
- private
18
-
19
- class OverridenHookCollections < RSpec::Core::Hooks::HookCollections
20
- def initialize(original)
21
- super(original.instance_eval("@owner"), original.instance_eval("@filterable_item_repo_class"))
22
- [:@before_example_hooks, :@after_example_hooks, :@before_context_hooks, :@after_context_hooks, :@around_example_hooks].each { |var|
23
- instance_variable_set(var, original.instance_eval("#{var}"))
24
- }
25
- @before_step_hooks = nil
26
- @after_step_hooks = nil
27
- end
28
-
29
- def run(position, scope, example_or_group)
30
- if scope == :step
31
- run_owned_hooks_for(position, scope, example_or_group)
32
- else
33
- super
34
- end
35
- end
36
-
37
- protected
38
-
39
- # TODO: This code is highly related to the RSpec internals.
40
- # It should be supported with every new RSpec version
41
- def matching_hooks_for(position, scope, example_or_group)
42
- if scope == :step
43
- repo = hooks_for(position, scope) || example_or_group.example_group.hooks.hooks_for(position, scope)
44
- metadata = case example_or_group
45
- when RSpec::Core::ExampleGroup then
46
- example_or_group.class.metadata
47
- else
48
- example_or_group.metadata
49
- end
50
- repo.nil? ? EMPTY_HOOK_ARRAY : repo.items_for(metadata)
51
- else
52
- super
53
- end
54
- end
55
-
56
- def hooks_for(position, scope)
57
- if scope == :step
58
- position == :before ? @before_step_hooks : @after_step_hooks
59
- else
60
- super
61
- end
62
- end
63
-
64
- def ensure_hooks_initialized_for(position, scope)
65
- if scope == :step
66
- if position == :before
67
- @before_step_hooks ||= @filterable_item_repo_class.new(:all?)
68
- else
69
- @after_step_hooks ||= @filterable_item_repo_class.new(:all?)
70
- end
71
- else
72
- super
73
- end
74
- end
75
-
76
- SCOPES = [:example, :context, :step]
77
-
78
- def known_scope?(scope)
79
- SCOPES.include?(scope) || super(scope)
80
- end
81
-
82
- end
83
- end
84
- end
85
- end
86
-
@@ -1,5 +0,0 @@
1
- module AllureRSpec # :nodoc:
2
- module Version # :nodoc:
3
- STRING = '0.7.7'
4
- end
5
- end
data/logo.png DELETED
Binary file
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
- require 'tempfile'
3
-
4
- describe "Some another spec", :feature => ["Some Feature"], :severity => :normal do
5
-
6
- before(:suite) do
7
- puts "before suite"
8
- end
9
-
10
- after(:suite) do
11
- puts "after suite"
12
- end
13
-
14
- it "10 cannot be greater than 19", :story => ["Some story"], :testId => 10 do
15
- expect(10).to be > 19
16
- end
17
-
18
- it "4 must not be equal to 5", :testId => 20 do
19
- expect(5).to be eql(4)
20
- end
21
- end
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
- require 'tempfile'
3
-
4
- describe AllureRSpec, :feature => "Basics" do
5
-
6
- before(:suite) do
7
- puts "before suite"
8
- end
9
-
10
- before(:context) do
11
- puts "before context"
12
- end
13
-
14
- before(:step) do |s|
15
- puts "before step #{s.current_step}"
16
- end
17
-
18
- before(:example) do
19
- puts "before example"
20
- end
21
-
22
- after(:step) do |s|
23
- puts "after step #{s.current_step}"
24
- end
25
-
26
- after(:example) do
27
- puts "after example"
28
- end
29
-
30
- after(:suite) do
31
- puts "after suite"
32
- end
33
-
34
- after(:context) do
35
- puts "after all"
36
- end
37
-
38
- it "should build", :story => "Main story" do |e|
39
- e.attach_file "test-file1", Tempfile.new("test")
40
- e.step "step1" do |step|
41
- step.attach_file "test-file2", Tempfile.new("test")
42
- end
43
-
44
- e.step "step2" do |step|
45
- step.attach_file "logo", File.new("logo.png")
46
- expect(5).to be > 1
47
- end
48
-
49
- e.step "step3" do
50
- expect(0).to eq(1)
51
- end
52
- end
53
-
54
- it "should be failed example" do
55
- fail_spec "Failure"
56
- end
57
-
58
- def fail_spec(desc)
59
- raise RSpec::Expectations::ExpectationNotMetError.new(desc)
60
- end
61
-
62
- it "should raise exception" do |e|
63
-
64
- e.step "step1" do
65
- expect(5).to be > 1
66
- end
67
-
68
- e.step "step2" do
69
- raise "Undesired exception"
70
- end
71
-
72
- end
73
-
74
- it "is a pending example"
75
-
76
- context "some context" do
77
- it do |e|
78
- expect("aa").to eq("aa")
79
- end
80
-
81
- it do |e|
82
- expect(5).to eq(6)
83
- end
84
- end
85
-
86
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'When I test allure rspec' do
4
- before(:all) do
5
- puts 'Before all in foo spec'
6
- end
7
-
8
- it 'should do something' do
9
- puts 'In the test'
10
- expect(true).not_to be_nil
11
- end
12
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Example', feature: 'Some feature', story: 'some_story' do
4
- it 'first test case' do
5
- #pass
6
- end
7
-
8
- it 'second test case' do
9
- #pass
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
- require 'tempfile'
3
-
4
- describe "Some feature", :feature do
5
- describe "Some story", :story do
6
- it "20 should be greater than 19", :story do
7
- expect(20).to be > 19
8
- end
9
- end
10
-
11
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
- require "set"
3
-
4
- shared_examples_for "a collection" do
5
- let(:collection) { described_class.new([7, 2, 4]) }
6
-
7
- context "initialized with 3 items" do
8
- it "says it has three items" do
9
- expect(collection.size).to be 3
10
- end
11
- end
12
-
13
- describe "#include?" do
14
- context "with an an item that is in the collection" do
15
- it "returns true" do
16
- expect(collection.include?(7)).to be true
17
- end
18
- end
19
-
20
- context "with an an item that is not in the collection" do
21
- it "returns false" do
22
- expect(collection.include?(9)).to be false
23
- end
24
- end
25
- end
26
- end
27
-
28
- describe Array do
29
- it_behaves_like "a collection"
30
- end
31
-
32
- describe Set do
33
- it_behaves_like "a collection"
34
- end
@@ -1,20 +0,0 @@
1
- require 'rspec'
2
- require 'allure-rspec'
3
- require 'nokogiri'
4
-
5
- RSpec.configure do |c|
6
- c.include AllureRSpec::Adaptor
7
-
8
- c.before(:suite) do
9
- puts 'Before Suite Spec helper'
10
- end
11
-
12
- c.before(:all) do
13
- puts 'Before all Spec helper'
14
- end
15
- end
16
-
17
- AllureRSpec.configure do |c|
18
- c.output_dir = "allure"
19
- end
20
-