rspec-axlsx-formatter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +7 -0
- data/lib/rspec/axlsx/formatter.rb +18 -0
- data/lib/rspec/axlsx/formatter/core.rb +11 -0
- data/lib/rspec/axlsx/formatter/version.rb +7 -0
- data/lib/rspec/axlsx/formatter_rspec2.rb +0 -0
- data/lib/rspec/axlsx/formatter_rspec3.rb +204 -0
- data/lib/rspec/axlsx/rake/rspec.rb +21 -0
- data/lib/rspec/axlsx/rake/rspec_loader.rb +2 -0
- data/rspec-axlsx-formatter.gemspec +25 -0
- data/spec/rspec/axlsx/formatter_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5cf35884f591642312cbe72c2f463b606ddb6c9a
|
4
|
+
data.tar.gz: 8b56708adbc43c36955362b0e2bc78562fad9ca8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ab87387b1aa65a642d09218693f113710f51fb13523b39b3f25dc742a014fe182326fc0dbf115af4631b3b96c4d54ef62ea36f28400e11e1a2036fa9bb29dad
|
7
|
+
data.tar.gz: fbb3d0d89d299dd03862a9f7182e07a0833046da61412ccbe5c172b7234cd5812a34dc4041ee0faa0367eb5948467ba02513eb6d6cf7db228489116125478fe8
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 yasuhiroki
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Rspec::Axlsx::Formatter
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rspec-axlsx-formatter'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rspec-axlsx-formatter
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/rspec-axlsx-formatter/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "rspec/axlsx/formatter/version"
|
2
|
+
require "rspec/core"
|
3
|
+
#require "rspec/core/formatters/base_formatter"
|
4
|
+
|
5
|
+
module Rspec
|
6
|
+
#class Formatter < ::RSpec::Core::Formatters::BaseFormatter
|
7
|
+
rspec_version = Gem::Version.new(::RSpec::Core::Version::STRING)
|
8
|
+
rspec_3 = Gem::Version.new('3.0.0')
|
9
|
+
RSPEC_3_AVAILABLE = rspec_version >= rspec_3
|
10
|
+
|
11
|
+
if RSPEC_3_AVAILABLE
|
12
|
+
require "rspec/axlsx/formatter_rspec3"
|
13
|
+
AxlsxFormatter = Rspec::Axlsx::FormatterRSpec3
|
14
|
+
else
|
15
|
+
require "rspec/axlsx/formatter_rspec2"
|
16
|
+
AxlsxFormatter = Rspec::Axlsx::FormatterRSpec2
|
17
|
+
end
|
18
|
+
end
|
File without changes
|
@@ -0,0 +1,204 @@
|
|
1
|
+
require "rspec/core"
|
2
|
+
require "axlsx"
|
3
|
+
require "axlsx/package"
|
4
|
+
require "rspec/core/formatters/base_formatter"
|
5
|
+
require "rspec/axlsx/formatter/core"
|
6
|
+
|
7
|
+
require "pp"
|
8
|
+
|
9
|
+
module Rspec
|
10
|
+
module Axlsx
|
11
|
+
#class Formatter < ::RSpec::Core::Formatters::BaseFormatter
|
12
|
+
class FormatterRSpec3 < ::RSpec::Core::Formatters::BaseFormatter
|
13
|
+
::RSpec::Core::Formatters.register self,
|
14
|
+
:start, :example_group_started, :stop,
|
15
|
+
:example_passed, :example_failed
|
16
|
+
|
17
|
+
ALL_IN_ONE_SHEET = 0
|
18
|
+
|
19
|
+
def initialize(*)
|
20
|
+
super ::Axlsx::Package.new
|
21
|
+
|
22
|
+
@workbook = output.workbook
|
23
|
+
@example_groups = []
|
24
|
+
@current_time = Time.now
|
25
|
+
|
26
|
+
@example_num = 0
|
27
|
+
|
28
|
+
#@describe_column = ["Expected"]
|
29
|
+
@describe_column = []
|
30
|
+
|
31
|
+
@sheet_mode = ALL_IN_ONE_SHEET
|
32
|
+
end
|
33
|
+
|
34
|
+
def start(notification)
|
35
|
+
end
|
36
|
+
|
37
|
+
def example_group_started(notification)
|
38
|
+
@example_groups.push(notification.group)
|
39
|
+
end
|
40
|
+
|
41
|
+
def example_group_finished(notification)
|
42
|
+
end
|
43
|
+
|
44
|
+
def example_passed(notification)
|
45
|
+
@example_groups.push(notification.example)
|
46
|
+
end
|
47
|
+
|
48
|
+
def example_failed(notification)
|
49
|
+
@example_groups.push(notification.example)
|
50
|
+
end
|
51
|
+
|
52
|
+
def stop(notification)
|
53
|
+
to_sheet
|
54
|
+
output.use_shared_strings = true
|
55
|
+
output.serialize("report.xlsx")
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def success?(example)
|
61
|
+
example.execution_result.status == :passed
|
62
|
+
end
|
63
|
+
|
64
|
+
def has_status?(example)
|
65
|
+
example.respond_to?(:execution_result)
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_sheet
|
69
|
+
convert_to_sheet do |worksheet|
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def sheet_style(worksheet)
|
74
|
+
worksheet.column_widths(*[nil].concat(max_example_depth.times.map{5}))
|
75
|
+
#worksheet.column_widths(nil, 5, 5)
|
76
|
+
end
|
77
|
+
|
78
|
+
def sheet_header(worksheet)
|
79
|
+
worksheet.add_row do |row|
|
80
|
+
row.add_cell('No' , style: header_style)
|
81
|
+
row.add_cell('Test Case' , style: header_style)
|
82
|
+
max_example_depth.times{row.add_cell('', style: header_style)}
|
83
|
+
@describe_column.each do |c|
|
84
|
+
row.add_cell(c, style: header_style)
|
85
|
+
end
|
86
|
+
row.add_cell('Result' , style: header_style)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def convert_to_sheet
|
91
|
+
if @sheet_mode == ALL_IN_ONE_SHEET
|
92
|
+
@workbook.add_worksheet do |worksheet|
|
93
|
+
sheet_header(worksheet)
|
94
|
+
@example_groups.each do |example_group|
|
95
|
+
add_sheet_row(worksheet, example_group)
|
96
|
+
end
|
97
|
+
sheet_style(worksheet)
|
98
|
+
end
|
99
|
+
else
|
100
|
+
transepose =
|
101
|
+
@example_groups.inject({}) do |h, example_group|
|
102
|
+
h[example_group.example.file_path] ||= []
|
103
|
+
h[example_group.example.file_path].push(example_group)
|
104
|
+
h
|
105
|
+
end
|
106
|
+
transepose.each do |k, v|
|
107
|
+
@workbook.add_worksheet do |worksheet|
|
108
|
+
yield(worksheet)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def add_sheet_row(worksheet, example_group)
|
115
|
+
worksheet.add_row do |row|
|
116
|
+
if has_status?(example_group)
|
117
|
+
@example_num += 1
|
118
|
+
row.add_cell(@example_num, style: idx_column_style)
|
119
|
+
example_depth(example_group).times do
|
120
|
+
row.add_cell("", style: grey_style)
|
121
|
+
end
|
122
|
+
row.add_cell(example_group.description)
|
123
|
+
offset = max_example_depth - example_depth(example_group) + @describe_column.length
|
124
|
+
offset.times do
|
125
|
+
row.add_cell("")
|
126
|
+
end
|
127
|
+
if success?(example_group)
|
128
|
+
row.add_cell("T", style: success_style)
|
129
|
+
else
|
130
|
+
row.add_cell("F", style: failed_style)
|
131
|
+
end
|
132
|
+
else
|
133
|
+
row.add_cell("", style: pink_style)
|
134
|
+
example_depth(example_group).times do
|
135
|
+
row.add_cell("", style: grey_style)
|
136
|
+
end
|
137
|
+
row.add_cell(example_group.description)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def max_example_depth
|
143
|
+
@max_example_depth ||=
|
144
|
+
@example_groups.map{|e| example_depth(e)}.max
|
145
|
+
end
|
146
|
+
|
147
|
+
def example_depth(example)
|
148
|
+
if has_status?(example)
|
149
|
+
example.example_group.parent_groups.select{|p| p != example}.length
|
150
|
+
else
|
151
|
+
example.parent_groups.select{|p| p != example}.length
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def style_hash
|
156
|
+
{
|
157
|
+
header_style: {
|
158
|
+
bg_color: 'F4FA58',
|
159
|
+
b: true,
|
160
|
+
border: { style: :thin, color: '666666' },
|
161
|
+
},
|
162
|
+
idx_column_style: {
|
163
|
+
bg_color: 'FFDD99',
|
164
|
+
b: true,
|
165
|
+
border: { style: :thin, color: '666666', edges: [:right] },
|
166
|
+
},
|
167
|
+
test_case_style: {
|
168
|
+
},
|
169
|
+
success_style: {
|
170
|
+
bg_color: '58FA58',
|
171
|
+
},
|
172
|
+
failed_style: {
|
173
|
+
bg_color: 'FE2E2E',
|
174
|
+
},
|
175
|
+
grey_space_style: {
|
176
|
+
bg_color: 'CCCCCC',
|
177
|
+
},
|
178
|
+
pink_space_style: {
|
179
|
+
bg_color: '6CEEC',
|
180
|
+
},
|
181
|
+
}
|
182
|
+
end
|
183
|
+
|
184
|
+
def header_style
|
185
|
+
@header_style ||= @workbook.styles.add_style(style_hash[:header_style])
|
186
|
+
end
|
187
|
+
def pink_style
|
188
|
+
@pink_style ||= @workbook.styles.add_style(style_hash[:idx_column_style].merge(style_hash[:pink_space_style]))
|
189
|
+
end
|
190
|
+
def grey_style
|
191
|
+
@grey_style ||= @workbook.styles.add_style(style_hash[:grey_space_style])
|
192
|
+
end
|
193
|
+
def success_style
|
194
|
+
@success_style ||= @workbook.styles.add_style(style_hash[:success_style])
|
195
|
+
end
|
196
|
+
def failed_style
|
197
|
+
@failed_style ||= @workbook.styles.add_style(style_hash[:failed_style])
|
198
|
+
end
|
199
|
+
def idx_column_style
|
200
|
+
@idx_column_style ||= @workbook.styles.add_style(style_hash[:idx_column_style])
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :axlsx do
|
2
|
+
namespace :setup do
|
3
|
+
task :spec_report_cleanup do
|
4
|
+
rm_rf ENV["XLSX_REPORT"] || "spec/xlsx"
|
5
|
+
end
|
6
|
+
|
7
|
+
task :rspec => :spec_report_cleanup do
|
8
|
+
setup_spec_opts
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup_spec_opts(*extra_options)
|
12
|
+
base_opts = [
|
13
|
+
"--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
|
14
|
+
"--format", "Rspec::Axlsx::FormatterRSpec3"
|
15
|
+
]
|
16
|
+
|
17
|
+
spec_opts = (base_opts + extra_options).join(" ")
|
18
|
+
ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec/axlsx/formatter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rspec-axlsx-formatter"
|
8
|
+
spec.version = Rspec::Axlsx::Formatter::VERSION
|
9
|
+
spec.authors = ["yasuhiroki"]
|
10
|
+
spec.email = ["yasuhiroki.duck@gmail.com"]
|
11
|
+
spec.summary = %q{Generate rspec report as xlsx file}
|
12
|
+
spec.description = %q{Generate rspec report as xlsx file.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.add_dependency 'axlsx'
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-axlsx-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yasuhiroki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: axlsx
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
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: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Generate rspec report as xlsx file.
|
70
|
+
email:
|
71
|
+
- yasuhiroki.duck@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/rspec/axlsx/formatter.rb
|
84
|
+
- lib/rspec/axlsx/formatter/core.rb
|
85
|
+
- lib/rspec/axlsx/formatter/version.rb
|
86
|
+
- lib/rspec/axlsx/formatter_rspec2.rb
|
87
|
+
- lib/rspec/axlsx/formatter_rspec3.rb
|
88
|
+
- lib/rspec/axlsx/rake/rspec.rb
|
89
|
+
- lib/rspec/axlsx/rake/rspec_loader.rb
|
90
|
+
- rspec-axlsx-formatter.gemspec
|
91
|
+
- spec/rspec/axlsx/formatter_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
homepage: ''
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.2.2
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Generate rspec report as xlsx file
|
117
|
+
test_files:
|
118
|
+
- spec/rspec/axlsx/formatter_spec.rb
|
119
|
+
- spec/spec_helper.rb
|