allure-rspec 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/allure-rspec.rb +13 -4
- data/lib/allure-rspec/adaptor.rb +2 -2
- data/lib/allure-rspec/builder.rb +37 -22
- data/lib/allure-rspec/dsl.rb +2 -3
- data/lib/allure-rspec/formatter.rb +19 -8
- data/lib/allure-rspec/version.rb +1 -1
- data/spec/another_spec.rb +2 -2
- data/spec/extend_steps_spec.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 012d9f82fef3280defb7a7bf0279304b7bc5faed
|
4
|
+
data.tar.gz: 8b0e5ecb45a6a704abfbe64ba2438950b441f846
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daac4d24b366f3ce2cc20bf0750784df753c44a4c46dedd173dcdbdec05ab42042330185b2e9d3b508eeaf95e0991e43808e8e58f8e3f3fbeff6802b7499d8dc
|
7
|
+
data.tar.gz: ce94edd8becef81deadbe5230ec408081645e2f683486cbc69109f027365f60c052ee1e198a80c18f9911e670573eaac9c9764604484e9d144f7b788e31a8346
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,7 @@ Adaptor to use the Allure framework along with the RSpec
|
|
4
4
|
|
5
5
|
## What's new
|
6
6
|
|
7
|
+
* *0.4.1* - Support for before/after(:step) hooks.
|
7
8
|
* *0.3.1* - Allure 1.4.0 format support.
|
8
9
|
|
9
10
|
## Setup
|
@@ -38,6 +39,10 @@ your current directory.
|
|
38
39
|
```ruby
|
39
40
|
describe MySpec do
|
40
41
|
|
42
|
+
before(:step) do |s|
|
43
|
+
puts "Before step #{s.current_step}"
|
44
|
+
end
|
45
|
+
|
41
46
|
it "should be steps enabled" do
|
42
47
|
|
43
48
|
step "step1" do
|
data/lib/allure-rspec.rb
CHANGED
@@ -11,17 +11,26 @@ module AllureRSpec
|
|
11
11
|
module Config
|
12
12
|
class << self
|
13
13
|
attr_accessor :output_dir
|
14
|
-
attr_accessor :rspec
|
15
14
|
|
16
15
|
DEFAULT_OUTPUT_DIR = 'allure/data'
|
17
16
|
|
18
17
|
def output_dir
|
19
18
|
@output_dir || DEFAULT_OUTPUT_DIR
|
20
19
|
end
|
20
|
+
end
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
class Context
|
24
|
+
attr_accessor :rspec
|
25
|
+
|
26
|
+
def rspec
|
27
|
+
@rspec
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class << self
|
32
|
+
def context
|
33
|
+
@context ||= Context.new
|
25
34
|
end
|
26
35
|
end
|
27
36
|
|
data/lib/allure-rspec/adaptor.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module AllureRSpec
|
2
2
|
module Adaptor
|
3
3
|
def self.included(base)
|
4
|
-
AllureRSpec
|
4
|
+
AllureRSpec.context.rspec = base
|
5
5
|
base.send :include, AllureRSpec::DSL
|
6
|
-
if RSpec.configuration.formatters.find_all {|f| f.is_a?(AllureRSpec::Formatter)}.empty?
|
6
|
+
if RSpec.configuration.formatters.find_all { |f| f.is_a?(AllureRSpec::Formatter) }.empty?
|
7
7
|
RSpec.configuration.add_formatter(AllureRSpec::Formatter)
|
8
8
|
end
|
9
9
|
RSpec::Core::ExampleGroup.send :include, AllureRSpec::Hooks
|
data/lib/allure-rspec/builder.rb
CHANGED
@@ -13,28 +13,29 @@ module AllureRSpec
|
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
-
def start_suite(title)
|
16
|
+
def start_suite(title, labels = [:severity => :normal])
|
17
17
|
init_suites
|
18
18
|
MUTEX.synchronize do
|
19
|
-
puts "Starting
|
19
|
+
puts "Starting case_or_suite #{title} with labels #{labels}"
|
20
20
|
self.suites[title] = {
|
21
21
|
:title => title,
|
22
22
|
:start => timestamp,
|
23
23
|
:tests => {},
|
24
|
+
:labels => labels
|
24
25
|
}
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def start_test(suite, test,
|
29
|
+
def start_test(suite, test, labels = [:severity => :normal])
|
29
30
|
MUTEX.synchronize do
|
30
|
-
puts "Starting test #{suite}.#{test}"
|
31
|
+
puts "Starting test #{suite}.#{test} with labels #{labels}"
|
31
32
|
self.suites[suite][:tests][test] = {
|
32
33
|
:title => test,
|
33
34
|
:start => timestamp,
|
34
|
-
:severity => severity,
|
35
35
|
:failure => nil,
|
36
36
|
:steps => {},
|
37
|
-
:attachments => []
|
37
|
+
:attachments => [],
|
38
|
+
:labels => labels,
|
38
39
|
}
|
39
40
|
end
|
40
41
|
end
|
@@ -65,13 +66,12 @@ module AllureRSpec
|
|
65
66
|
text
|
66
67
|
end
|
67
68
|
|
68
|
-
def start_step(suite, test, step
|
69
|
+
def start_step(suite, test, step)
|
69
70
|
MUTEX.synchronize do
|
70
71
|
puts "Starting step #{suite}.#{test}.#{step}"
|
71
72
|
self.suites[suite][:tests][test][:steps][step] = {
|
72
73
|
:title => step,
|
73
74
|
:start => timestamp,
|
74
|
-
:severity => severity || :normal,
|
75
75
|
:attachments => []
|
76
76
|
}
|
77
77
|
end
|
@@ -102,7 +102,7 @@ module AllureRSpec
|
|
102
102
|
def stop_suite(title)
|
103
103
|
init_suites
|
104
104
|
MUTEX.synchronize do
|
105
|
-
puts "Stopping
|
105
|
+
puts "Stopping case_or_suite #{title}"
|
106
106
|
self.suites[title][:stop] = timestamp
|
107
107
|
end
|
108
108
|
end
|
@@ -134,26 +134,17 @@ module AllureRSpec
|
|
134
134
|
xml.step(:start => step_obj[:start] || 0, :stop => step_obj[:stop] || 0, :status => step_obj[:status]) do
|
135
135
|
xml.send :name, step_title
|
136
136
|
xml.send :title, step_title
|
137
|
-
xml
|
138
|
-
step_obj[:attachments].each do |attach|
|
139
|
-
xml.attachment :source => attach[:source], :title => attach[:title], :size => attach[:size], :type => attach[:type]
|
140
|
-
end
|
141
|
-
end
|
137
|
+
xml_attachments(xml, step_obj[:attachments])
|
142
138
|
end
|
143
139
|
end
|
144
140
|
end
|
145
|
-
xml
|
146
|
-
|
147
|
-
xml.attachment :source => attach[:source], :title => attach[:title], :size => attach[:size], :type => attach[:type]
|
148
|
-
end
|
149
|
-
end
|
150
|
-
xml.labels do
|
151
|
-
xml.label :name => "severity", :value => test[:severity]
|
152
|
-
end
|
141
|
+
xml_attachments(xml, test[:attachments])
|
142
|
+
xml_labels(xml, suite[:labels].merge(test[:labels]))
|
153
143
|
xml.parameters
|
154
144
|
end
|
155
145
|
end
|
156
146
|
end
|
147
|
+
xml_labels(xml, suite[:labels])
|
157
148
|
end
|
158
149
|
end
|
159
150
|
xml = builder.to_xml
|
@@ -162,6 +153,30 @@ module AllureRSpec
|
|
162
153
|
end
|
163
154
|
suites_xml
|
164
155
|
end
|
156
|
+
|
157
|
+
private
|
158
|
+
|
159
|
+
def xml_attachments(xml, attachments)
|
160
|
+
xml.attachments do
|
161
|
+
attachments.each do |attach|
|
162
|
+
xml.attachment :source => attach[:source], :title => attach[:title], :size => attach[:size], :type => attach[:type]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def xml_labels(xml, labels)
|
168
|
+
xml.labels do
|
169
|
+
labels.each do |name, value|
|
170
|
+
if value.is_a?(Array)
|
171
|
+
value.each do |v|
|
172
|
+
xml.label :name => name, :value => v
|
173
|
+
end
|
174
|
+
else
|
175
|
+
xml.label :name => name, :value => value
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
165
180
|
end
|
166
181
|
end
|
167
182
|
end
|
data/lib/allure-rspec/dsl.rb
CHANGED
@@ -2,7 +2,6 @@ require 'digest'
|
|
2
2
|
require 'mimemagic'
|
3
3
|
module AllureRSpec
|
4
4
|
module DSL
|
5
|
-
|
6
5
|
def __mutex
|
7
6
|
@@__mutex ||= Mutex.new
|
8
7
|
end
|
@@ -19,10 +18,10 @@ module AllureRSpec
|
|
19
18
|
__mutex.synchronize do
|
20
19
|
begin
|
21
20
|
@@__current_step = step
|
22
|
-
|
21
|
+
AllureRSpec.context.rspec.send :run_hook, :before, :step, example
|
23
22
|
yield
|
24
23
|
ensure
|
25
|
-
|
24
|
+
AllureRSpec.context.rspec.send :run_hook, :after, :step, example
|
26
25
|
@@__current_step = nil
|
27
26
|
end
|
28
27
|
end
|
@@ -6,6 +6,8 @@ module AllureRSpec
|
|
6
6
|
|
7
7
|
class Formatter < RSpec::Core::Formatters::BaseFormatter
|
8
8
|
|
9
|
+
ALLOWED_LABELS = [:feature, :story, :severity, :language, :framework]
|
10
|
+
|
9
11
|
def example_failed(example)
|
10
12
|
AllureRSpec::Builder.stop_test(
|
11
13
|
example.metadata[:example_group][:description_args].first,
|
@@ -24,7 +26,7 @@ module AllureRSpec
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def example_group_started(group)
|
27
|
-
AllureRSpec::Builder.start_suite(group.metadata[:example_group][:description_args].first)
|
29
|
+
AllureRSpec::Builder.start_suite(group.metadata[:example_group][:description_args].first, labels(group))
|
28
30
|
super
|
29
31
|
end
|
30
32
|
|
@@ -44,7 +46,7 @@ module AllureRSpec
|
|
44
46
|
def example_started(example)
|
45
47
|
suite = example.metadata[:example_group][:description_args].first
|
46
48
|
test = example.metadata[:description]
|
47
|
-
AllureRSpec::Builder.start_test(suite, test)
|
49
|
+
AllureRSpec::Builder.start_test(suite, test, labels(example))
|
48
50
|
super
|
49
51
|
end
|
50
52
|
|
@@ -62,15 +64,24 @@ module AllureRSpec
|
|
62
64
|
file.write(xml)
|
63
65
|
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
xsd = Nokogiri::XML::Schema(File.read(Pathname.new(File.dirname(__FILE__)).join("../../allure-model.xsd")))
|
68
|
+
doc = Nokogiri::XML(File.read(out_file))
|
69
|
+
|
70
|
+
xsd.validate(doc).each do |error|
|
71
|
+
$stderr.puts error.message
|
72
|
+
end
|
71
73
|
end
|
72
74
|
super
|
73
75
|
end
|
74
76
|
|
77
|
+
private
|
78
|
+
|
79
|
+
def labels(example_or_group)
|
80
|
+
ALLOWED_LABELS.
|
81
|
+
map { |label| [label, example_or_group.metadata[label]] }.
|
82
|
+
find_all { |value| !value[1].nil? }.
|
83
|
+
inject({}) { |res, value| res.merge(value[0] => value[1]) }
|
84
|
+
end
|
85
|
+
|
75
86
|
end
|
76
87
|
end
|
data/lib/allure-rspec/version.rb
CHANGED
data/spec/another_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
|
-
describe "Some another spec" do
|
4
|
+
describe "Some another spec", :feature => ["Some Feature"], :severity => :normal do
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
puts "before each"
|
@@ -11,7 +11,7 @@ describe "Some another spec" do
|
|
11
11
|
puts "after each"
|
12
12
|
end
|
13
13
|
|
14
|
-
it "10 cannot be greater than 19" do
|
14
|
+
it "10 cannot be greater than 19", :story => ["Some story"] do
|
15
15
|
10.should > 19
|
16
16
|
end
|
17
17
|
|
data/spec/extend_steps_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
|
-
describe AllureRSpec do
|
4
|
+
describe AllureRSpec, :feature => "Basics" do
|
5
5
|
|
6
6
|
before(:suite) do
|
7
7
|
puts "before suite"
|
@@ -35,7 +35,7 @@ describe AllureRSpec do
|
|
35
35
|
puts "after all"
|
36
36
|
end
|
37
37
|
|
38
|
-
it "should build" do
|
38
|
+
it "should build", :story => "Main story" do
|
39
39
|
attach_file "test-file1", Tempfile.new("test")
|
40
40
|
step "step1" do
|
41
41
|
attach_file "test-file2", Tempfile.new("test")
|
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: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Sadykov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -141,5 +141,5 @@ rubyforge_project:
|
|
141
141
|
rubygems_version: 2.0.3
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
|
-
summary: allure-rspec-0.4.
|
144
|
+
summary: allure-rspec-0.4.2
|
145
145
|
test_files: []
|