allure-ruby-api 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7b5743b49f4e5186687b76112d3a72297864f1b0
4
+ data.tar.gz: 41ad0365da3f6f394dcbc64de2853b28ad7e96a2
5
+ SHA512:
6
+ metadata.gz: 453a355f90c0cd609a034934466af917a73ba4535bf9f86a67494f1405165c68c0216084328d0396bba69dadb59adfdafa129ee174dd6cae75740c204ace4f32
7
+ data.tar.gz: 69cddb5bbec3a7ef1f40b45973023e9faf00b8b27f70bf338b1114d0790dd5a8f182a9064d995fc269fb6bbcbab537ffb49585d33490357b8fe73b34c6ec9030
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ *.class
2
+
3
+ # Package Files #
4
+ *.jar
5
+ *.war
6
+ *.ear
7
+ *.gem
8
+
9
+ target
10
+ allure
11
+ .idea
12
+ *.iml
13
+ *.ipr
14
+ *.iws
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'rspec', '~> 2.14.0'
5
+ gem 'nokogiri', '~> 1.6.0'
6
+ gem 'mimemagic'
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ allure-ruby-api (0.1)
5
+ mimemagic
6
+ nokogiri (~> 1.6.0)
7
+ rspec (~> 2.14.0)
8
+ uuid
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ diff-lcs (1.2.5)
14
+ macaddr (1.7.1)
15
+ systemu (~> 2.6.2)
16
+ mimemagic (0.2.1)
17
+ mini_portile (0.6.0)
18
+ nokogiri (1.6.3.1)
19
+ mini_portile (= 0.6.0)
20
+ rake (10.3.2)
21
+ rspec (2.14.1)
22
+ rspec-core (~> 2.14.0)
23
+ rspec-expectations (~> 2.14.0)
24
+ rspec-mocks (~> 2.14.0)
25
+ rspec-core (2.14.8)
26
+ rspec-expectations (2.14.5)
27
+ diff-lcs (>= 1.1.3, < 2.0)
28
+ rspec-mocks (2.14.6)
29
+ systemu (2.6.4)
30
+ uuid (2.3.7)
31
+ macaddr (~> 1.0)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ allure-ruby-api!
38
+ bundler
39
+ mimemagic
40
+ nokogiri (~> 1.6.0)
41
+ rake
42
+ rspec (~> 2.14.0)
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Allure Ruby API
2
+
3
+ This is a helper library containing the basics for any ruby-based Allure adaptor.
4
+ Using it you can easily implement the adaptor for your favourite ruby testing library or
5
+ you can just create the report of any other kind using the basic Allure terms.
6
+
7
+ ## Setup
8
+
9
+ Add the dependency to your Gemfile
10
+
11
+ ```ruby
12
+ gem 'allure-ruby-api'
13
+ ```
14
+
15
+ ## Advanced options
16
+
17
+ You can specify the directory where the Allure test results will appear. By default it would be 'allure/data' within
18
+ your current directory.
19
+
20
+ ```ruby
21
+ AllureRubyApi.configure do |c|
22
+ c.output_dir = "/whatever/you/like"
23
+ end
24
+ ```
25
+
26
+ ## Usage examples
27
+
28
+ ```ruby
29
+ AllureRubyApi::Builder.start_suite "some_suite", :severity => :normal
30
+ AllureRubyApi::Builder.start_test "some_suite", "some_test", :feature => "Some feature", :severity => :critical
31
+ AllureRubyApi::Builder.start_step "some_suite", "some_test", "first step"
32
+ AllureRubyApi::Builder.add_attachment "some_suite", "some_test", :file => Tempfile.new("somefile")
33
+ AllureRubyApi::Builder.stop_step "some_suite", "some_test", "first step"
34
+ AllureRubyApi::Builder.start_step "some_suite", "some_test", "second step"
35
+ AllureRubyApi::Builder.add_attachment "some_suite", "some_test", :step => "second step", :file => Tempfile.new("somefile")
36
+ AllureRubyApi::Builder.stop_step "some_suite", "some_test", "second step"
37
+ AllureRubyApi::Builder.start_step "some_suite", "some_test", "third step"
38
+ AllureRubyApi::Builder.stop_step "some_suite", "some_test", "third step", :failed
39
+ AllureRubyApi::Builder.stop_test "some_suite", "some_test", :status => :broken, :exception => Exception.new("some error")
40
+ AllureRubyApi::Builder.stop_suite "some_suite"
41
+
42
+ # This will generate the results within your output directory
43
+ AllureRubyApi::Builder.build!
44
+ ```
@@ -0,0 +1,171 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
3
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
+ xmlns:qa="urn:model.allure.qatools.yandex.ru"
5
+ targetNamespace="urn:model.allure.qatools.yandex.ru">
6
+
7
+ <xs:element name="test-suite" type="qa:test-suite-result"/>
8
+
9
+ <xs:complexType name="test-suite-result">
10
+ <xs:all>
11
+ <xs:element name="name" type="xs:string"/>
12
+ <xs:element name="title" type="xs:string" minOccurs="0"/>
13
+ <xs:element name="description" type="qa:description" minOccurs="0"/>
14
+ <xs:element name="test-cases" type="qa:test-cases-result" minOccurs="0"/>
15
+ <xs:element name="labels" type="qa:labels" minOccurs="0"/>
16
+ </xs:all>
17
+ <xs:attribute name="start" type="xs:long" use="required"/>
18
+ <xs:attribute name="stop" type="xs:long" use="required"/>
19
+ <xs:attribute name="version" type="xs:string"/>
20
+ </xs:complexType>
21
+
22
+ <xs:complexType name="test-cases-result">
23
+ <xs:sequence>
24
+ <xs:element name="test-case" type="qa:test-case-result" maxOccurs="unbounded" minOccurs="0"/>
25
+ </xs:sequence>
26
+ </xs:complexType>
27
+
28
+ <xs:complexType name="test-case-result">
29
+ <xs:all>
30
+ <xs:element name="name" type="xs:string"/>
31
+ <xs:element name="title" type="xs:string" minOccurs="0"/>
32
+ <xs:element name="description" type="qa:description" minOccurs="0"/>
33
+ <xs:element name="failure" type="qa:failure" minOccurs="0"/>
34
+ <xs:element name="steps" type="qa:steps" minOccurs="0"/>
35
+ <xs:element name="attachments" type="qa:attachments" minOccurs="0"/>
36
+ <xs:element name="labels" type="qa:labels" minOccurs="0"/>
37
+ <xs:element name="parameters" type="qa:parameters" minOccurs="0"/>
38
+ </xs:all>
39
+ <xs:attribute name="start" type="xs:long" use="required"/>
40
+ <xs:attribute name="stop" type="xs:long" use="required"/>
41
+ <xs:attribute name="status" type="qa:status" use="required"/>
42
+ </xs:complexType>
43
+
44
+ <xs:complexType name="steps">
45
+ <xs:sequence>
46
+ <xs:element name="step" type="qa:step" minOccurs="0" maxOccurs="unbounded"/>
47
+ </xs:sequence>
48
+ </xs:complexType>
49
+
50
+ <xs:complexType name="step">
51
+ <xs:all>
52
+ <xs:element name="name" type="xs:string"/>
53
+ <xs:element name="title" type="xs:string" minOccurs="0"/>
54
+ <xs:element name="attachments" type="qa:attachments" minOccurs="0"/>
55
+ <xs:element name="steps" type="qa:steps" minOccurs="0"/>
56
+ </xs:all>
57
+ <xs:attribute name="start" type="xs:long" use="required"/>
58
+ <xs:attribute name="stop" type="xs:long" use="required"/>
59
+ <xs:attribute name="status" type="qa:status" use="required"/>
60
+ </xs:complexType>
61
+
62
+ <xs:complexType name="failure">
63
+ <xs:all>
64
+ <xs:element name="message" type="xs:string"/>
65
+ <xs:element name="stack-trace" type="xs:string" minOccurs="0"/>
66
+ </xs:all>
67
+ </xs:complexType>
68
+
69
+ <xs:complexType name="labels">
70
+ <xs:sequence>
71
+ <xs:element name="label" type="qa:label" minOccurs="0" maxOccurs="unbounded"/>
72
+ </xs:sequence>
73
+ </xs:complexType>
74
+
75
+ <xs:complexType name="label">
76
+ <xs:attribute name="name" type="xs:string" use="required"/>
77
+ <xs:attribute name="value" type="xs:string" use="required"/>
78
+ </xs:complexType>
79
+
80
+ <xs:complexType name="parameters">
81
+ <xs:sequence>
82
+ <xs:element name="parameter" type="qa:parameter" minOccurs="0" maxOccurs="unbounded"/>
83
+ </xs:sequence>
84
+ </xs:complexType>
85
+
86
+ <xs:complexType name="parameter">
87
+ <xs:attribute name="name" type="xs:string" use="required"/>
88
+ <xs:attribute name="value" type="xs:string" use="required"/>
89
+ <xs:attribute name="kind" type="qa:parameter-kind" use="required"/>
90
+ </xs:complexType>
91
+
92
+ <xs:simpleType name="parameter-kind">
93
+ <xs:restriction base="xs:string">
94
+ <xs:enumeration value="argument"/>
95
+ <xs:enumeration value="system-property"/>
96
+ <xs:enumeration value="environment-variable"/>
97
+ </xs:restriction>
98
+ </xs:simpleType>
99
+
100
+ <xs:complexType name="attachments">
101
+ <xs:sequence>
102
+ <xs:element name="attachment" type="qa:attachment" minOccurs="0" maxOccurs="unbounded"/>
103
+ </xs:sequence>
104
+ </xs:complexType>
105
+
106
+ <xs:complexType name="attachment">
107
+ <xs:attribute name="title" type="xs:string" use="required"/>
108
+ <xs:attribute name="source" type="xs:string" use="required"/>
109
+ <xs:attribute name="type" type="xs:string" use="required"/>
110
+ <xs:attribute name="size" type="xs:int"/>
111
+ </xs:complexType>
112
+
113
+ <!--Deprecated, will be removed in 1.4.0-->
114
+ <xs:simpleType name="attachment-type">
115
+ <xs:restriction base="xs:string">
116
+ <xs:enumeration value="txt"/>
117
+ <xs:enumeration value="html"/>
118
+ <xs:enumeration value="xml"/>
119
+ <xs:enumeration value="png"/>
120
+ <xs:enumeration value="jpg"/>
121
+ <xs:enumeration value="json"/>
122
+ <xs:enumeration value="other"/>
123
+ </xs:restriction>
124
+ </xs:simpleType>
125
+
126
+ <xs:simpleType name="status">
127
+ <xs:restriction base="xs:string">
128
+ <xs:enumeration value="failed"/>
129
+ <xs:enumeration value="broken"/>
130
+ <xs:enumeration value="passed"/>
131
+ <xs:enumeration value="canceled"/>
132
+ <xs:enumeration value="pending"/>
133
+ </xs:restriction>
134
+ </xs:simpleType>
135
+
136
+ <xs:simpleType name="label-name">
137
+ <xs:restriction base="xs:string">
138
+ <xs:enumeration value="feature"/>
139
+ <xs:enumeration value="story"/>
140
+ <xs:enumeration value="severity"/>
141
+ <xs:enumeration value="language"/>
142
+ <xs:enumeration value="framework"/>
143
+ </xs:restriction>
144
+ </xs:simpleType>
145
+
146
+ <xs:simpleType name="severity-level">
147
+ <xs:restriction base="xs:string">
148
+ <xs:enumeration value="blocker"/>
149
+ <xs:enumeration value="critical"/>
150
+ <xs:enumeration value="normal"/>
151
+ <xs:enumeration value="minor"/>
152
+ <xs:enumeration value="trivial"/>
153
+ </xs:restriction>
154
+ </xs:simpleType>
155
+
156
+ <xs:complexType name="description">
157
+ <xs:simpleContent>
158
+ <xs:extension base="xs:string">
159
+ <xs:attribute name="type" type="qa:description-type" default="text"/>
160
+ </xs:extension>
161
+ </xs:simpleContent>
162
+ </xs:complexType>
163
+
164
+ <xs:simpleType name="description-type">
165
+ <xs:restriction base="xs:string">
166
+ <xs:enumeration value="markdown"/>
167
+ <xs:enumeration value="text"/>
168
+ <xs:enumeration value="html"/>
169
+ </xs:restriction>
170
+ </xs:simpleType>
171
+ </xs:schema>
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
+ require "allure-ruby-api/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'allure-ruby-api'
7
+ s.version = AllureRubyApi::Version::STRING
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Ilya Sadykov']
10
+ s.email = ['smecsia@yandex-team.ru']
11
+ s.description = %q{This is a helper library containing the basics for any ruby-based Allure adaptor.}
12
+ s.summary = "allure-ruby-api-#{AllureRubyApi::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', '~> 2.14.0'
22
+ s.add_dependency 'nokogiri', '~> 1.6.0'
23
+ s.add_dependency 'uuid'
24
+ s.add_dependency 'mimemagic'
25
+
26
+ s.add_development_dependency 'bundler'
27
+ s.add_development_dependency 'rake'
28
+ end
@@ -0,0 +1,213 @@
1
+ require 'digest'
2
+ require 'mimemagic'
3
+ require 'nokogiri'
4
+ require 'uuid'
5
+
6
+ module AllureRubyApi
7
+
8
+ class Builder
9
+ class << self
10
+ attr_accessor :suites
11
+ MUTEX = Mutex.new
12
+
13
+ def start_suite(suite, labels = [:severity => :normal])
14
+ init_suites
15
+ MUTEX.synchronize do
16
+ puts "Starting case_or_suite #{suite} with labels #{labels}"
17
+ self.suites[suite] = {
18
+ :title => suite,
19
+ :start => timestamp,
20
+ :tests => {},
21
+ :labels => labels
22
+ }
23
+ end
24
+ end
25
+
26
+ def start_test(suite, test, labels = [:severity => :normal])
27
+ MUTEX.synchronize do
28
+ puts "Starting test #{suite}.#{test} with labels #{labels}"
29
+ self.suites[suite][:tests][test] = {
30
+ :title => test,
31
+ :start => timestamp,
32
+ :failure => nil,
33
+ :steps => {},
34
+ :attachments => [],
35
+ :labels => labels,
36
+ }
37
+ end
38
+ end
39
+
40
+ def stop_test(suite, test, result = {})
41
+ self.suites[suite][:tests][test][:steps].each do |step_title, step|
42
+ if step[:stop].nil? || step[:stop] == 0
43
+ stop_step(suite, test, step_title, result[:status])
44
+ end
45
+ end
46
+ MUTEX.synchronize do
47
+ puts "Stopping test #{suite}.#{test}"
48
+ self.suites[suite][:tests][test][:stop] = timestamp(result[:finished_at])
49
+ self.suites[suite][:tests][test][:start] = timestamp(result[:started_at])
50
+ self.suites[suite][:tests][test][:status] = result[:status]
51
+ if (result[:status].to_sym != :passed)
52
+ self.suites[suite][:tests][test][:failure] = {
53
+ :stacktrace => ((result[:exception] && result[:exception].backtrace) || []).map { |s| s.to_s }.join("\r\n"),
54
+ :message => result[:exception].to_s,
55
+ }
56
+ end
57
+
58
+ end
59
+ end
60
+
61
+ def start_step(suite, test, step)
62
+ MUTEX.synchronize do
63
+ puts "Starting step #{suite}.#{test}.#{step}"
64
+ self.suites[suite][:tests][test][:steps][step] = {
65
+ :title => step,
66
+ :start => timestamp,
67
+ :attachments => []
68
+ }
69
+ end
70
+ end
71
+
72
+ def add_attachment(suite, test, opts = {:step => nil, :file => nil, :mime_type => nil})
73
+ raise "File cannot be nil!" if opts[:file].nil?
74
+ step = opts[:step]
75
+ file = opts[:file]
76
+ title = opts[:title] || file.basename
77
+ puts "Adding attachment #{opts[:title]} to #{suite}.#{test}#{step.nil ? "" : ".#{step}"}"
78
+ dir = Pathname.new(config.output_dir)
79
+ FileUtils.mkdir_p(dir)
80
+ file_extname = File.extname(file.path.downcase)
81
+ mime_type = opts[:mime_type] || MimeMagic.by_path(file.path) || "text/plain"
82
+ attachment = dir.join("#{Digest::SHA256.file(file.path).hexdigest}-attachment#{(file_extname.empty?) ? '' : file_extname}")
83
+ FileUtils.cp(file.path, attachment)
84
+ attach = {
85
+ :type => mime_type,
86
+ :title => title,
87
+ :source => attachment.basename,
88
+ :size => File.stat(attachment).size
89
+ }
90
+ if step.nil?
91
+ self.suites[suite][:tests][test][:attachments] << attach
92
+ else
93
+ self.suites[suite][:tests][test][:steps][step][:attachments] << attach
94
+ end
95
+ end
96
+
97
+ def stop_step(suite, test, step, status = :passed)
98
+ MUTEX.synchronize do
99
+ puts "Stopping step #{suite}.#{test}.#{step}"
100
+ self.suites[suite][:tests][test][:steps][step][:stop] = timestamp
101
+ self.suites[suite][:tests][test][:steps][step][:status] = status
102
+ end
103
+ end
104
+
105
+ def stop_suite(title)
106
+ init_suites
107
+ MUTEX.synchronize do
108
+ puts "Stopping case_or_suite #{title}"
109
+ self.suites[title][:stop] = timestamp
110
+ end
111
+ end
112
+
113
+ def build!(opts = {:empty_dir => true}, &block)
114
+ FileUtils.rm_rf config.output_dir if opts[:empty_dir]
115
+ suites_xml = []
116
+ self.suites.each do |suite_title, suite|
117
+ builder = Nokogiri::XML::Builder.new do |xml|
118
+ xml.send "ns2:test-suite", :start => suite[:start] || 0, :stop => suite[:stop] || 0, 'xmlns' => '', "xmlns:ns2" => "urn:model.allure.qatools.yandex.ru" do
119
+ xml.send :name, suite_title
120
+ xml.send :title, suite_title
121
+ xml.send "test-cases" do
122
+ suite[:tests].each do |test_title, test|
123
+ xml.send "test-case", :start => test[:start] || 0, :stop => test[:stop] || 0, :status => test[:status] do
124
+ xml.send :name, test_title
125
+ xml.send :title, test_title
126
+ unless test[:failure].nil?
127
+ xml.failure do
128
+ xml.message test[:failure][:message]
129
+ xml.send "stack-trace", test[:failure][:stacktrace]
130
+ end
131
+ end
132
+ xml.steps do
133
+ test[:steps].each do |step_title, step_obj|
134
+ xml.step(:start => step_obj[:start] || 0, :stop => step_obj[:stop] || 0, :status => step_obj[:status]) do
135
+ xml.send :name, step_title
136
+ xml.send :title, step_title
137
+ xml_attachments(xml, step_obj[:attachments])
138
+ end
139
+ end
140
+ end
141
+ xml_attachments(xml, test[:attachments])
142
+ xml_labels(xml, suite[:labels].merge(test[:labels]))
143
+ xml.parameters
144
+ end
145
+ end
146
+ end
147
+ xml_labels(xml, suite[:labels])
148
+ end
149
+ end
150
+ xml = builder.to_xml
151
+ xml = yield suite, xml if block_given?
152
+ dir = Pathname.new(config.output_dir)
153
+ FileUtils.mkdir_p(dir)
154
+ out_file = dir.join("#{UUID.new.generate}-testsuite.xml")
155
+ File.open(out_file, 'w+') do |file|
156
+ file.write(validate_xml(xml))
157
+ end
158
+ suites_xml << xml
159
+ end
160
+ suites_xml
161
+ end
162
+
163
+ private
164
+
165
+ def config
166
+ AllureRubyApi::Config
167
+ end
168
+
169
+ def init_suites
170
+ MUTEX.synchronize {
171
+ self.suites ||= {}
172
+ }
173
+ end
174
+
175
+ def timestamp(time = nil)
176
+ ((time || Time.now).to_f * 1000).to_i
177
+ end
178
+
179
+ def validate_xml(xml)
180
+ xsd = Nokogiri::XML::Schema(File.read(Pathname.new(File.dirname(__FILE__)).join("../../allure-model-#{AllureRubyApi::Version::STRING}.xsd")))
181
+ doc = Nokogiri::XML(xml)
182
+
183
+ xsd.validate(doc).each do |error|
184
+ $stderr.puts error.message
185
+ end
186
+ xml
187
+ end
188
+
189
+
190
+ def xml_attachments(xml, attachments)
191
+ xml.attachments do
192
+ attachments.each do |attach|
193
+ xml.attachment :source => attach[:source], :title => attach[:title], :size => attach[:size], :type => attach[:type]
194
+ end
195
+ end
196
+ end
197
+
198
+ def xml_labels(xml, labels)
199
+ xml.labels do
200
+ labels.each do |name, value|
201
+ if value.is_a?(Array)
202
+ value.each do |v|
203
+ xml.label :name => name, :value => v
204
+ end
205
+ else
206
+ xml.label :name => name, :value => value
207
+ end
208
+ end
209
+ end
210
+ end
211
+ end
212
+ end
213
+ end
@@ -0,0 +1,34 @@
1
+ require 'digest'
2
+ require 'mimemagic'
3
+ module AllureRubyApi
4
+ module DSL
5
+
6
+
7
+ def step(step, &block)
8
+ suite = self.example.metadata[:example_group][:description_args].first
9
+ test = self.example.metadata[:description]
10
+ AllureRSpec::Builder.start_step(suite, test, step)
11
+ __with_step step, &block
12
+ AllureRSpec::Builder.stop_step(suite, test, step)
13
+ end
14
+
15
+ def attach_file(title, file, mime_type = nil)
16
+ step = current_step
17
+ dir = Pathname.new(AllureRSpec::Config.output_dir)
18
+ FileUtils.mkdir_p(dir)
19
+ file_extname = File.extname(file.path.downcase)
20
+ mime_type ||= MimeMagic.by_path(file.path) || "text/plain"
21
+ attachment = dir.join("#{Digest::SHA256.file(file.path).hexdigest}-attachment#{(file_extname.empty?) ? '' : file_extname}")
22
+ FileUtils.cp(file.path, attachment)
23
+ suite = self.example.metadata[:example_group][:description_args].first
24
+ test = self.example.metadata[:description]
25
+ AllureRubyApi::Builder.add_attachment(suite, test, {
26
+ :type => type,
27
+ :title => title,
28
+ :source => attachment.basename,
29
+ :size => File.stat(attachment).size
30
+ }, step)
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,5 @@
1
+ module AllureRubyApi # :nodoc:
2
+ module Version # :nodoc:
3
+ STRING = '0.1'
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ require 'allure-ruby-api/version'
2
+ require 'allure-ruby-api/builder'
3
+
4
+ module AllureRubyApi
5
+ module Config
6
+ class << self
7
+ attr_accessor :output_dir
8
+
9
+ DEFAULT_OUTPUT_DIR = 'allure/data'
10
+
11
+ def output_dir
12
+ @output_dir || DEFAULT_OUTPUT_DIR
13
+ end
14
+ end
15
+ end
16
+
17
+ class << self
18
+ def configure(&block)
19
+ yield Config
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ require 'tempfile'
3
+
4
+ describe AllureRubyApi do
5
+ let(:builder) { AllureRubyApi::Builder }
6
+
7
+ it "should build xml report" do
8
+
9
+ builder.start_suite "some_suite", :severity => :normal
10
+ builder.start_test "some_suite", "some_test", :feature => "Some feature"
11
+ builder.start_step "some_suite", "some_test", "first step"
12
+ builder.stop_step "some_suite", "some_test", "first step"
13
+ builder.start_step "some_suite", "some_test", "second step"
14
+ builder.stop_step "some_suite", "some_test", "second step"
15
+ builder.start_step "some_suite", "some_test", "third step"
16
+ builder.stop_step "some_suite", "some_test", "third step", :failed
17
+ builder.stop_test "some_suite", "some_test", :status => :broken, :exception => Exception.new("some error")
18
+ builder.stop_suite "some_suite"
19
+
20
+ builder.build! {|suite, xml|
21
+ xml.should_not be_empty
22
+ xml.should include("<ns2:test-suite")
23
+ xml.should include("<title>some_suite</title>")
24
+ xml
25
+ }
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec'
2
+ require 'allure-ruby-api'
3
+
4
+ AllureRubyApi.configure do |c|
5
+ c.output_dir = "allure"
6
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: allure-ruby-api
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Ilya Sadykov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 2.14.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 2.14.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.6.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: uuid
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mimemagic
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: This is a helper library containing the basics for any ruby-based Allure
98
+ adaptor.
99
+ email:
100
+ - smecsia@yandex-team.ru
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - README.md
109
+ - allure-model-1.4.0.xsd
110
+ - allure-ruby-api.gemspec
111
+ - lib/allure-ruby-api.rb
112
+ - lib/allure-ruby-api/builder.rb
113
+ - lib/allure-ruby-api/dsl.rb
114
+ - lib/allure-ruby-api/version.rb
115
+ - spec/extend_steps_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: http://allure.qatools.ru
118
+ licenses:
119
+ - Apache2
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.0.3
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: allure-ruby-api-0.1
141
+ test_files: []