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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05082235365532bded92d2552c949b7805673d66
4
- data.tar.gz: 7c4da451b610f0a98110e6ab3593f09787ee39e8
3
+ metadata.gz: 012d9f82fef3280defb7a7bf0279304b7bc5faed
4
+ data.tar.gz: 8b0e5ecb45a6a704abfbe64ba2438950b441f846
5
5
  SHA512:
6
- metadata.gz: 65e2fa2160ee9d75d5bc5cf1691db2ca4f01d72380bf5f0408d8dcfd7673f9bd7cbcf2a56b5b891fc1891508b9f441d199cc8af5d44bf98cf6fa513805f79017
7
- data.tar.gz: 28c23526a6ea7733dbf8820f31768016d11d5e8779e8dd8aae53d746cc7911c20bb5126da606cafa3c9471491d85da95c6bb7c8c69b62127ea9577353d3376e1
6
+ metadata.gz: daac4d24b366f3ce2cc20bf0750784df753c44a4c46dedd173dcdbdec05ab42042330185b2e9d3b508eeaf95e0991e43808e8e58f8e3f3fbeff6802b7499d8dc
7
+ data.tar.gz: ce94edd8becef81deadbe5230ec408081645e2f683486cbc69109f027365f60c052ee1e198a80c18f9911e670573eaac9c9764604484e9d144f7b788e31a8346
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- allure-rspec (0.4.0)
4
+ allure-rspec (0.4.2)
5
5
  mimemagic
6
6
  nokogiri (~> 1.6.0)
7
7
  rspec (~> 2.14.0)
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
- def rspec
23
- @rspec
24
- end
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
 
@@ -1,9 +1,9 @@
1
1
  module AllureRSpec
2
2
  module Adaptor
3
3
  def self.included(base)
4
- AllureRSpec::Config.rspec = base
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
@@ -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 suite #{title}"
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, severity = :normal)
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, severity = :normal)
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 suite #{title}"
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.attachments do
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.attachments do
146
- test[:attachments].each do |attach|
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
@@ -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
- Config.rspec.send :run_hook, :before, :step, example
21
+ AllureRSpec.context.rspec.send :run_hook, :before, :step, example
23
22
  yield
24
23
  ensure
25
- Config.rspec.send :run_hook, :after, :step, example
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
- #xsd = Nokogiri::XML::Schema(File.read("allure-model.xsd"))
66
- #doc = Nokogiri::XML(File.read(out_file))
67
- #
68
- #xsd.validate(doc).each do |error|
69
- # puts error.message
70
- #end
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
@@ -1,5 +1,5 @@
1
1
  module AllureRSpec # :nodoc:
2
2
  module Version # :nodoc:
3
- STRING = '0.4.1'
3
+ STRING = '0.4.2'
4
4
  end
5
5
  end
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
 
@@ -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.1
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-24 00:00:00.000000000 Z
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.1
144
+ summary: allure-rspec-0.4.2
145
145
  test_files: []