minitest-colorin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/lib/minitest/colorin/version.rb +5 -0
- data/lib/minitest/colorin.rb +179 -0
- data/lib/minitest/colorin_plugin.rb +11 -0
- data/minitest-colorin.gemspec +27 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac07cc5672ad5e29fb08203b4074ff87970c713e
|
4
|
+
data.tar.gz: 427351fe794d88ec82f48113eabf62e8e9ea4d0a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3484e22641f9806eac23e9de7728c7fdd2b39b19e27e2368e560bce93435dc9f3d3b6c5b7936730787993ccf3d2ebe52ae2b970dc56bc0cffd059e1e5e57ff31
|
7
|
+
data.tar.gz: cc1d85888fe006825ff295e64c84e693f3d24b20715b25153038bf9a719c30001e6671c82b9fa2ce3bba838e55d51cbf67d20da2a79a610a2ad867f27e1ca00f
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
minitest-colorin
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.3.0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Gabriel Naiman
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Minitest::Colorin
|
2
|
+
|
3
|
+
Minitest colored reporter
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'minitest-colorin'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install minitest-colorin
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Add the following to the top of your minitest file or you spec_helper file:
|
24
|
+
|
25
|
+
require 'minitest/colorin'
|
26
|
+
|
27
|
+
This will replace Minitest's default reports with minitest-colorin reporter.
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/minitest-colorin.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
40
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'minitest'
|
2
|
+
require 'colorin'
|
3
|
+
|
4
|
+
module Minitest
|
5
|
+
class Colorin
|
6
|
+
|
7
|
+
class TestID
|
8
|
+
|
9
|
+
REGEXP = /test_(?<number>\d{4})_(?<name>.+)/
|
10
|
+
|
11
|
+
attr_reader :context, :name, :number
|
12
|
+
|
13
|
+
def initialize(result)
|
14
|
+
@context = result.class.name.gsub('::', ' > ')
|
15
|
+
match = result.name.match REGEXP
|
16
|
+
@name = match[:name]
|
17
|
+
@number = match[:number]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
LABELS = {
|
23
|
+
'.' => 'PASS ',
|
24
|
+
'S' => 'SKIP ',
|
25
|
+
'F' => 'FAIL ',
|
26
|
+
'E' => 'ERROR'
|
27
|
+
}
|
28
|
+
|
29
|
+
GROUPS = {
|
30
|
+
'.' => :passed,
|
31
|
+
'S' => :skips,
|
32
|
+
'F' => :failures,
|
33
|
+
'E' => :errors
|
34
|
+
}
|
35
|
+
|
36
|
+
COLORS = {
|
37
|
+
tests: :blue_light,
|
38
|
+
passed: :green_light,
|
39
|
+
failures: :red_light,
|
40
|
+
errors: :yellow_light,
|
41
|
+
skips: :cyan_light,
|
42
|
+
assertions: :magenta_light
|
43
|
+
}
|
44
|
+
|
45
|
+
attr_reader :io, :previous_context, :results, :started_at
|
46
|
+
|
47
|
+
def initialize(io)
|
48
|
+
@io = io
|
49
|
+
@previous_context = nil
|
50
|
+
@results = []
|
51
|
+
end
|
52
|
+
|
53
|
+
def start
|
54
|
+
@started_at = Time.now
|
55
|
+
io.puts "Started at #{started_at}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def record(result)
|
59
|
+
@results << result
|
60
|
+
|
61
|
+
test_id = TestID.new result
|
62
|
+
|
63
|
+
if test_id.context != @previous_context
|
64
|
+
io.puts
|
65
|
+
io.puts colorin(test_id.context).white.bold
|
66
|
+
@previous_context = test_id.context
|
67
|
+
end
|
68
|
+
|
69
|
+
label = colorin(LABELS[result.result_code]).send COLORS[GROUPS[result.result_code]]
|
70
|
+
number = colorin(test_id.number).dark
|
71
|
+
time = colorin("(#{result.time.round(3)}s)").dark
|
72
|
+
error = case result.result_code
|
73
|
+
when 'E' then colorin("#{error_message(result)}").dark.send(COLORS[:errors])
|
74
|
+
when 'F' then colorin("#{relative_path(result.failures[0].location)}").send(COLORS[:failures])
|
75
|
+
else nil
|
76
|
+
end
|
77
|
+
|
78
|
+
io.puts " #{label} #{number} #{test_id.name} #{time} #{error}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def passed?
|
82
|
+
results.all? { |r| r.failures.empty? }
|
83
|
+
end
|
84
|
+
|
85
|
+
def report
|
86
|
+
io.puts
|
87
|
+
|
88
|
+
print_detail_of :skips
|
89
|
+
print_detail_of :failures
|
90
|
+
print_detail_of :errors
|
91
|
+
|
92
|
+
print_total_time
|
93
|
+
|
94
|
+
print_summary
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def passed
|
100
|
+
@passed ||= results.select(&:passed?)
|
101
|
+
end
|
102
|
+
|
103
|
+
def skips
|
104
|
+
@skips ||= results.select(&:skipped?)
|
105
|
+
end
|
106
|
+
|
107
|
+
def errors
|
108
|
+
@errors ||= results.select(&:error?)
|
109
|
+
end
|
110
|
+
|
111
|
+
def failures
|
112
|
+
@failures ||= results - passed - skips - errors
|
113
|
+
end
|
114
|
+
|
115
|
+
def assertions_count
|
116
|
+
results.inject(0) { |n,r| n + r.assertions }
|
117
|
+
end
|
118
|
+
|
119
|
+
def print_detail_of(group)
|
120
|
+
color = COLORS[group]
|
121
|
+
group_results = send group
|
122
|
+
|
123
|
+
if group_results.any?
|
124
|
+
io.puts colorin(group.to_s.upcase).bold.underline.send(color)
|
125
|
+
group_results.each_with_index do |r,i|
|
126
|
+
test_id = TestID.new r
|
127
|
+
number = "#{i+1}) "
|
128
|
+
indent = ' ' * number.size
|
129
|
+
io.puts "#{number}#{test_id.context} > #{test_id.name}"
|
130
|
+
if group == :errors
|
131
|
+
io.puts colorin("#{indent}#{r.failures[0].exception.class}: #{r.failures[0].exception.message}").send(color)
|
132
|
+
r.failures[0].backtrace.each do |line|
|
133
|
+
io.puts colorin("#{indent}#{relative_path(line)}").dark
|
134
|
+
end
|
135
|
+
else
|
136
|
+
r.failures[0].message.split("\n").each do |line|
|
137
|
+
io.puts colorin("#{indent}#{line}").send(color)
|
138
|
+
end
|
139
|
+
io.puts colorin("#{indent}#{relative_path(r.failures[0].location)}").dark
|
140
|
+
end
|
141
|
+
io.puts if i < group_results.count - 1
|
142
|
+
end
|
143
|
+
io.puts
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def print_summary
|
148
|
+
summary = [
|
149
|
+
colorin("#{results.count} tests").send(COLORS[:tests]),
|
150
|
+
colorin("#{passed.count} passed").send(COLORS[:passed]),
|
151
|
+
colorin("#{failures.count} failures").send(COLORS[:failures]),
|
152
|
+
colorin("#{errors.count} errors").send(COLORS[:errors]),
|
153
|
+
colorin("#{skips.count} skips").send(COLORS[:skips]),
|
154
|
+
colorin("#{assertions_count} assertions").send(COLORS[:assertions]),
|
155
|
+
]
|
156
|
+
|
157
|
+
io.puts summary.join(', ')
|
158
|
+
io.puts
|
159
|
+
end
|
160
|
+
|
161
|
+
def print_total_time
|
162
|
+
io.puts "Finished in #{Time.now - started_at} seconds"
|
163
|
+
io.puts
|
164
|
+
end
|
165
|
+
|
166
|
+
def error_message(result)
|
167
|
+
"#{result.failures[0].exception.class}: #{result.failures[0].exception.message}"
|
168
|
+
end
|
169
|
+
|
170
|
+
def relative_path(full_path)
|
171
|
+
full_path.gsub "#{Dir.pwd}/", ''
|
172
|
+
end
|
173
|
+
|
174
|
+
def colorin(text)
|
175
|
+
::Colorin.new text
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'minitest/colorin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'minitest-colorin'
|
8
|
+
spec.version = Minitest::Colorin::VERSION
|
9
|
+
spec.authors = ['Gabriel Naiman']
|
10
|
+
spec.email = ['gabynaiman@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Minitest colored reporter'
|
13
|
+
spec.description = 'Minitest colored reporter'
|
14
|
+
spec.homepage = 'https://github.com/gabynaiman/minitest-colorin'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'minitest', '~> 5.0'
|
23
|
+
spec.add_runtime_dependency 'colorin', '~> 1.0'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-colorin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriel Naiman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.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.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Minitest colored reporter
|
70
|
+
email:
|
71
|
+
- gabynaiman@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".ruby-gemset"
|
78
|
+
- ".ruby-version"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/minitest/colorin.rb
|
84
|
+
- lib/minitest/colorin/version.rb
|
85
|
+
- lib/minitest/colorin_plugin.rb
|
86
|
+
- minitest-colorin.gemspec
|
87
|
+
homepage: https://github.com/gabynaiman/minitest-colorin
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.5.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Minitest colored reporter
|
111
|
+
test_files: []
|