minitest-documentation 0.0.4 → 1.0.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 +4 -4
- data/README.md +2 -7
- data/Rakefile +8 -0
- data/lib/minitest/documentation.rb +3 -72
- data/lib/minitest/documentation_plugin.rb +43 -8
- data/minitest-documentation.gemspec +1 -1
- data/test/minitest/documentation_test.rb +26 -0
- data/test/minitest/test_case.rb +20 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 903b024afaacd5c5e1d47f8f01e86f457210fd09
|
4
|
+
data.tar.gz: 733731c8074c9ae06ded824f5235bd8dccfdaa3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 774dced2d39c8a68e4a1f0aa7ff9572e0997cefaa686b72afcedd2535803e36c21af74b5823a0e451a626a896e51d4074223756ec935fa6c5ce16bbf35464214
|
7
|
+
data.tar.gz: 16ec6acee8ad707ecdc3a78a9d67ec2697c23a83c1a97e41cee6962bf8d1eb94b356dae44688da8d30116c12a736e9c6f1795f482c9a0f2176303f9d615804b1
|
data/README.md
CHANGED
@@ -22,7 +22,8 @@ Minitest >= 5.0.0
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
Just pass `--documentation` as an argument while running your tests
|
25
|
+
Just pass `--documentation` as an argument while running your tests.
|
26
|
+
Or require `minitest/documentation` in your tests.
|
26
27
|
|
27
28
|
## What's the difference?
|
28
29
|
|
@@ -68,12 +69,6 @@ Epic Fail!
|
|
68
69
|
You have skipped tests. Run with --verbose for details.
|
69
70
|
```
|
70
71
|
|
71
|
-
### Color
|
72
|
-
If you add `--color` as an argument the output will be colorized
|
73
|
-
- `pass` => Green
|
74
|
-
- `skip` => Yellow
|
75
|
-
- `fail` => Red
|
76
|
-
|
77
72
|
## Contributing
|
78
73
|
|
79
74
|
1. Fork it ( http://github.com/teoljungberg/minitest-documentation/fork )
|
data/Rakefile
CHANGED
@@ -1,73 +1,4 @@
|
|
1
|
-
|
2
|
-
class DocumentationReporter < Reporter
|
3
|
-
ESC = "\e["
|
4
|
-
NND = "#{ESC}0m"
|
5
|
-
GREEN = "#{ESC}32m"
|
6
|
-
RED = "#{ESC}31m"
|
7
|
-
YELLOW = "#{ESC}33m"
|
1
|
+
require 'minitest'
|
8
2
|
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.documentation?
|
14
|
-
@documentation ||= false
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.color!
|
18
|
-
@color = true
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.color?
|
22
|
-
@color ||= false
|
23
|
-
end
|
24
|
-
|
25
|
-
def record result
|
26
|
-
output_klass_name result.class if self.class.documentation?
|
27
|
-
print_colorized_progress result if self.class.color?
|
28
|
-
|
29
|
-
if self.class.documentation?
|
30
|
-
test = test_name result
|
31
|
-
io.print " "
|
32
|
-
io.puts stringify_test_name(test)
|
33
|
-
end
|
34
|
-
io.print NND
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def color_code result
|
40
|
-
color_code = case result.result_code
|
41
|
-
when "."
|
42
|
-
GREEN
|
43
|
-
when "E", "F"
|
44
|
-
RED
|
45
|
-
when "S"
|
46
|
-
YELLOW
|
47
|
-
end
|
48
|
-
color_code
|
49
|
-
end
|
50
|
-
|
51
|
-
def print_colorized_progress result
|
52
|
-
io.print color_code(result)
|
53
|
-
io.print result.result_code unless self.class.documentation?
|
54
|
-
end
|
55
|
-
|
56
|
-
def output_klass_name k
|
57
|
-
if k != @klass
|
58
|
-
@klass = k
|
59
|
-
io.puts @klass
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_name o
|
64
|
-
o.instance_variable_get "@NAME"
|
65
|
-
end
|
66
|
-
|
67
|
-
def stringify_test_name test
|
68
|
-
test.
|
69
|
-
sub("test_", "").
|
70
|
-
gsub("_", " ")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
3
|
+
Minitest.load_plugins
|
4
|
+
Minitest::Documentation.documentation!
|
@@ -1,21 +1,56 @@
|
|
1
|
-
require 'minitest
|
1
|
+
require 'minitest'
|
2
2
|
|
3
3
|
module Minitest
|
4
4
|
def self.plugin_documentation_options opts, options
|
5
5
|
opts.on "--documentation", "Documentation formatter" do
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
opts.on "--color", "Colorize the output" do
|
10
|
-
DocumentationReporter.color!
|
6
|
+
Documentation.documentation!
|
11
7
|
end
|
12
8
|
end
|
13
9
|
|
14
10
|
def self.plugin_documentation_init options
|
15
|
-
if
|
11
|
+
if Documentation.documentation?
|
16
12
|
io = options.delete(:io) || $stdout
|
17
13
|
self.reporter.reporters.reject! {|o| o.is_a? ProgressReporter }
|
18
|
-
self.reporter.reporters <<
|
14
|
+
self.reporter.reporters << Documentation.new(io, options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Documentation < Reporter
|
19
|
+
INDENT = " "
|
20
|
+
|
21
|
+
def self.documentation!
|
22
|
+
@documentation = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.documentation?
|
26
|
+
@documentation ||= false
|
27
|
+
end
|
28
|
+
|
29
|
+
def record result
|
30
|
+
format_test_klass result
|
31
|
+
|
32
|
+
io.print INDENT
|
33
|
+
io.puts format_test_name(result)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def format_test_klass klass
|
39
|
+
@klass ||= ""
|
40
|
+
if klass.class != @klass
|
41
|
+
@klass = klass.class
|
42
|
+
io.puts @klass
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_name o
|
47
|
+
o.instance_variable_get "@NAME"
|
48
|
+
end
|
49
|
+
|
50
|
+
def format_test_name test
|
51
|
+
test_name(test).
|
52
|
+
sub("test_", "").
|
53
|
+
gsub("_", " ")
|
19
54
|
end
|
20
55
|
end
|
21
56
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'test_case'
|
2
|
+
require 'minitest/documentation'
|
3
|
+
|
4
|
+
module Minitest
|
5
|
+
class DocumentationFormatTest < TestCase
|
6
|
+
def setup
|
7
|
+
Documentation.documentation!
|
8
|
+
ExampleTest.generate_tests!
|
9
|
+
self.reporter = Documentation.new io
|
10
|
+
end
|
11
|
+
attr_accessor :reporter
|
12
|
+
|
13
|
+
def test_documentation_format
|
14
|
+
ExampleTest.run reporter
|
15
|
+
|
16
|
+
exp_format = <<-EOS
|
17
|
+
Minitest::TestCase::ExampleTest
|
18
|
+
a very long sentence
|
19
|
+
pass
|
20
|
+
verbosity
|
21
|
+
EOS
|
22
|
+
|
23
|
+
assert_equal exp_format, io.string
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module Minitest
|
5
|
+
class TestCase < Test
|
6
|
+
ExampleTest = Class.new(Test) {
|
7
|
+
i_suck_and_my_tests_are_order_dependent!
|
8
|
+
|
9
|
+
def self.generate_tests!
|
10
|
+
define_method(:test_pass) { assert 'truthy' }
|
11
|
+
define_method(:test_verbosity) { assert 'truthy' }
|
12
|
+
define_method(:test_a_very_long_sentence) { assert 'truthy' }
|
13
|
+
end
|
14
|
+
}
|
15
|
+
|
16
|
+
def io
|
17
|
+
@io ||= StringIO.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-documentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Teo Ljungberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -68,6 +68,8 @@ files:
|
|
68
68
|
- lib/minitest/documentation.rb
|
69
69
|
- lib/minitest/documentation_plugin.rb
|
70
70
|
- minitest-documentation.gemspec
|
71
|
+
- test/minitest/documentation_test.rb
|
72
|
+
- test/minitest/test_case.rb
|
71
73
|
homepage: https://github.com/teoljungberg/minitest-documentation
|
72
74
|
licenses:
|
73
75
|
- MIT
|
@@ -88,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
90
|
version: '0'
|
89
91
|
requirements: []
|
90
92
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.2.
|
93
|
+
rubygems_version: 2.2.2
|
92
94
|
signing_key:
|
93
95
|
specification_version: 4
|
94
96
|
summary: Rspec like documentation for Minitest
|