allure-rspec 0.2 → 0.3

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: fec41921ea99be5dcbb621773501e81924dd2905
4
- data.tar.gz: bfc84fc1048ed36b8c105fa9bbd1766aea1f6db8
3
+ metadata.gz: 76c5c9a1660e8ae8746b73e8fa6111c6261aa607
4
+ data.tar.gz: 8b5820b53d091ce34e3474d44ce65f3afb790fa3
5
5
  SHA512:
6
- metadata.gz: bfd123e24dd44780765cb33b997737e1358d6581c8342d9434b150b15fb704f29ef71ee914052d9f3196661b23dbb43905142c0803526a696cca1d40ca6f3199
7
- data.tar.gz: a7a649563839b91797810b8ed3d93f11c868d4b3f9f65f463c1dfb7b43996f6ecdb2d001e09859db5e31e658be672cd9b94a73efb719f70bedfe24f789b46f83
6
+ metadata.gz: b6c27669cf4e08e0c9095075931741c8a2cead92b037467837e2dd864b34dcd3864c9ed057fbc5005dfd1b0fa8e84ea9cd962259d2677884440fc6dde66337ee
7
+ data.tar.gz: 56d2544deeef8891b7bb37e5d105369eafece2959178ce8b9407b6ccec1892723aea9602166caae5f3bf58f81ee0328d731751d3fb8e5065cfec9f951ae1ec8f
data/Gemfile CHANGED
@@ -3,3 +3,4 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
  gem 'rspec', '~> 2.13.0'
5
5
  gem 'nokogiri', '~> 1.6.0'
6
+ gem 'mimemagic'
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- allure-rspec (0.1)
4
+ allure-rspec (0.3)
5
+ mimemagic
5
6
  nokogiri (~> 1.6.0)
6
7
  rspec (~> 2.13.0)
7
8
  uuid
@@ -10,8 +11,9 @@ GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
13
  diff-lcs (1.2.5)
13
- macaddr (1.6.1)
14
- systemu (~> 2.5.0)
14
+ macaddr (1.7.1)
15
+ systemu (~> 2.6.2)
16
+ mimemagic (0.2.1)
15
17
  mini_portile (0.5.2)
16
18
  nokogiri (1.6.0)
17
19
  mini_portile (~> 0.5.0)
@@ -24,7 +26,7 @@ GEM
24
26
  rspec-expectations (2.13.0)
25
27
  diff-lcs (>= 1.1.3, < 2.0)
26
28
  rspec-mocks (2.13.1)
27
- systemu (2.5.2)
29
+ systemu (2.6.4)
28
30
  uuid (2.3.7)
29
31
  macaddr (~> 1.0)
30
32
 
@@ -34,6 +36,7 @@ PLATFORMS
34
36
  DEPENDENCIES
35
37
  allure-rspec!
36
38
  bundler
39
+ mimemagic
37
40
  nokogiri (~> 1.6.0)
38
41
  rake
39
42
  rspec (~> 2.13.0)
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Adaptor to use the Allure framework along with the RSpec
4
4
 
5
+ ## What's new
6
+
7
+ * *0.3* - Allure 1.4.0 format support.
8
+
5
9
  ## Setup
6
10
 
7
11
  Add the dependency to your Gemfile
@@ -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>
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'rspec', '~> 2.13.0'
22
22
  s.add_dependency 'nokogiri', '~> 1.6.0'
23
23
  s.add_dependency 'uuid'
24
+ s.add_dependency 'mimemagic'
24
25
 
25
26
  s.add_development_dependency 'bundler'
26
27
  s.add_development_dependency 'rake'
@@ -81,6 +81,7 @@ module AllureRSpec
81
81
  :title => attachment[:title],
82
82
  :source => attachment[:source],
83
83
  :type => attachment[:type],
84
+ :size => attachment[:size],
84
85
  }
85
86
  if step.nil?
86
87
  self.suites[suite][:tests][test][:attachments] << attach
@@ -112,28 +113,40 @@ module AllureRSpec
112
113
  def each_suite_build(&block)
113
114
  suites_xml = []
114
115
  self.suites.each do |suite_title, suite|
115
- builder = Nokogiri::XML::Builder.new do
116
- send "test-suite", :start => suite[:start] || 0, :stop => suite[:stop] || 0 do
117
- title suite_title
118
- suite[:tests].each do |test_title, test|
119
- send "test-cases", :start => test[:start] || 0, :stop => test[:stop] || 0, :status => test[:status], :severity => test[:severity] do
120
- title test_title
121
- unless test[:failure].nil?
122
- failure do
123
- message test[:failure][:message]
124
- send "stack-trace", test[:failure][:stacktrace]
116
+ builder = Nokogiri::XML::Builder.new do |xml|
117
+ xml.send "ns2:test-suite", :start => suite[:start] || 0, :stop => suite[:stop] || 0, 'xmlns' => '', "xmlns:ns2" => "urn:model.allure.qatools.yandex.ru" do
118
+ xml.send "name", suite_title
119
+ xml.send "test-cases" do
120
+ suite[:tests].each do |test_title, test|
121
+ xml.send "test-case", :start => test[:start] || 0, :stop => test[:stop] || 0, :status => test[:status] do
122
+ xml.send "name", test_title
123
+ unless test[:failure].nil?
124
+ xml.failure do
125
+ xml.message test[:failure][:message]
126
+ xml.send "stack-trace", test[:failure][:stacktrace]
127
+ end
125
128
  end
126
- end
127
- test[:steps].each do |step_title, step_obj|
128
- steps(:start => step_obj[:start] || 0, :stop => step_obj[:stop] || 0, :status => step_obj[:status]) do
129
- title step_title
130
- step_obj[:attachments].each do |attach|
131
- attachment :source => attach[:source], :title => attach[:title], :type => attach[:type]
129
+ xml.steps do
130
+ test[:steps].each do |step_title, step_obj|
131
+ xml.step(:start => step_obj[:start] || 0, :stop => step_obj[:stop] || 0, :status => step_obj[:status]) do
132
+ xml.send "name", step_title
133
+ xml.attachments do
134
+ step_obj[:attachments].each do |attach|
135
+ xml.attachment :source => attach[:source], :title => attach[:title], :size => attach[:size], :type => attach[:type]
136
+ end
137
+ end
138
+ end
132
139
  end
133
140
  end
134
- end
135
- test[:attachments].each do |attach|
136
- attachment :source => attach[:source], :title => attach[:title], :type => attach[:type]
141
+ xml.attachments do
142
+ test[:attachments].each do |attach|
143
+ xml.attachment :source => attach[:source], :title => attach[:title], :size => attach[:size], :type => attach[:type]
144
+ end
145
+ end
146
+ xml.labels do
147
+ xml.label :name => "severity", :value => test[:severity]
148
+ end
149
+ xml.parameters
137
150
  end
138
151
  end
139
152
  end
@@ -1,3 +1,5 @@
1
+ require 'digest'
2
+ require 'mimemagic'
1
3
  module AllureRSpec
2
4
  module DSL
3
5
 
@@ -33,12 +35,20 @@ module AllureRSpec
33
35
 
34
36
  def attach_file(title, file)
35
37
  step = __current_step
38
+ dir = Pathname.new(AllureRSpec::Config.output_dir)
39
+ FileUtils.mkdir_p(dir)
40
+ file_extname = File.extname(file.path.downcase)
41
+ type = MimeMagic.by_path(file.path) || "text/plain"
42
+ attachment = dir.join("#{Digest::SHA256.file(file.path).hexdigest}-attachment#{(file_extname.empty?) ? '' : file_extname}")
43
+ FileUtils.cp(file.path, attachment)
36
44
  suite = self.example.metadata[:example_group][:description_args].first
37
45
  test = self.example.metadata[:description]
38
- type = :other
39
- file_extname = File.extname(file.path.downcase)
40
- type = file_extname if ALLOWED_ATTACH_EXTS.include?(file_extname)
41
- AllureRSpec::Builder.add_attachment(suite, test, {:type => type, :title => title, :source => file.path}, step)
46
+ AllureRSpec::Builder.add_attachment(suite, test, {
47
+ :type => type,
48
+ :title => title,
49
+ :source => attachment.basename,
50
+ :size => File.stat(attachment).size
51
+ }, step)
42
52
  end
43
53
  end
44
54
  end
@@ -45,14 +45,26 @@ module AllureRSpec
45
45
  super
46
46
  end
47
47
 
48
+ def start(example_count)
49
+ dir = Pathname.new(AllureRSpec::Config.output_dir)
50
+ FileUtils.rm_rf(dir)
51
+ end
52
+
48
53
  def stop
49
54
  AllureRSpec::Builder.each_suite_build do |suite, xml|
50
55
  dir = Pathname.new(AllureRSpec::Config.output_dir)
51
- FileUtils.rm_rf(dir)
52
56
  FileUtils.mkdir_p(dir)
53
- File.open(dir.join("#{UUID.new.generate}.xml"), 'w+') do |file|
57
+ out_file = dir.join("#{UUID.new.generate}.xml")
58
+ File.open(out_file, 'w+') do |file|
54
59
  file.write(xml)
55
60
  end
61
+
62
+ #xsd = Nokogiri::XML::Schema(File.read("allure-model.xsd"))
63
+ #doc = Nokogiri::XML(File.read(out_file))
64
+ #
65
+ #xsd.validate(doc).each do |error|
66
+ # puts error.message
67
+ #end
56
68
  end
57
69
  super
58
70
  end
@@ -1,5 +1,5 @@
1
1
  module AllureRSpec # :nodoc:
2
2
  module Version # :nodoc:
3
- STRING = '0.2'
3
+ STRING = '0.3'
4
4
  end
5
5
  end
Binary file
@@ -9,13 +9,13 @@ describe AllureRSpec do
9
9
  end
10
10
 
11
11
  step "step2" do
12
-
12
+ attach_file "logo", File.new("logo.png")
13
13
  5.should be > 1
14
14
  end
15
15
 
16
16
  step "step3" do
17
17
 
18
- 0.should == 0
18
+ 0.should == 1
19
19
  end
20
20
  end
21
- end
21
+ end
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.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Sadykov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-12 00:00:00.000000000 Z
11
+ date: 2014-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
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'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +105,7 @@ files:
91
105
  - Gemfile
92
106
  - Gemfile.lock
93
107
  - README.md
108
+ - allure-model.xsd
94
109
  - allure-rspec.gemspec
95
110
  - lib/allure-rspec.rb
96
111
  - lib/allure-rspec/adaptor.rb
@@ -98,6 +113,7 @@ files:
98
113
  - lib/allure-rspec/dsl.rb
99
114
  - lib/allure-rspec/formatter.rb
100
115
  - lib/allure-rspec/version.rb
116
+ - logo.png
101
117
  - spec/extend_steps_spec.rb
102
118
  - spec/spec_helper.rb
103
119
  homepage: http://allure.qatools.ru
@@ -123,5 +139,5 @@ rubyforge_project:
123
139
  rubygems_version: 2.0.3
124
140
  signing_key:
125
141
  specification_version: 4
126
- summary: allure-rspec-0.2
142
+ summary: allure-rspec-0.3
127
143
  test_files: []