minitest-reporters 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ module MiniTest
2
+ module RelativePosition
3
+ TEST_PADDING = 2
4
+ TEST_SIZE = 63
5
+ MARK_SIZE = 5
6
+ INFO_PADDING = 8
7
+
8
+ private
9
+
10
+ def print_with_info_padding(line)
11
+ puts pad(line, INFO_PADDING)
12
+ end
13
+
14
+ def pad(str, size)
15
+ ' ' * size + str
16
+ end
17
+
18
+ def pad_mark(str)
19
+ "%#{MARK_SIZE}s" % str
20
+ end
21
+
22
+ def pad_test(str)
23
+ pad("%-#{TEST_SIZE}s" % str, TEST_PADDING)
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,7 @@
1
1
  require "minitest/unit"
2
2
 
3
3
  module MiniTest
4
+ require "minitest/relative_position"
4
5
  require "minitest/reporter"
5
6
  require "minitest/reporter_runner"
6
7
  require "minitest/before_test_hook"
@@ -10,11 +10,13 @@ module MiniTest
10
10
  # @see https://github.com/seattlerb/minitest MiniTest
11
11
  class DefaultReporter
12
12
  include Reporter
13
+ include RelativePosition
13
14
 
14
15
  def initialize(options = {})
15
16
  @detailed_skip = options.fetch(:detailed_skip, true)
16
17
  @slow_count = options.fetch(:slow_count, 0)
17
18
  @slow_suite_count = options.fetch(:slow_suite_count, 0)
19
+ @fast_fail = options.fetch(:fast_fail, false)
18
20
  @test_times = []
19
21
  @suite_times = []
20
22
  @color = options.fetch(:color) do
@@ -46,11 +48,29 @@ module MiniTest
46
48
  end
47
49
 
48
50
  def failure(suite, test, test_runner)
49
- after_test(red('F'))
51
+ if @fast_fail
52
+ puts
53
+ puts suite.name
54
+ print pad_test(test)
55
+ print(red(pad_mark('FAIL')))
56
+ puts
57
+ print_info(test_runner.exception)
58
+ else
59
+ after_test(red('F'))
60
+ end
50
61
  end
51
62
 
52
63
  def error(suite, test, test_runner)
53
- after_test(red('E'))
64
+ if @fast_fail
65
+ puts
66
+ puts suite.name
67
+ print pad_test(test)
68
+ print(red(pad_mark('ERROR')))
69
+ puts
70
+ print_info(test_runner.exception)
71
+ else
72
+ after_test(red('E'))
73
+ end
54
74
  end
55
75
 
56
76
  def after_suite(suite)
@@ -67,11 +87,13 @@ module MiniTest
67
87
  puts
68
88
  puts colored_for(suite_result, status_line)
69
89
 
70
- runner.test_results.each do |suite, tests|
71
- tests.each do |test, test_runner|
72
- if message = message_for(test_runner)
73
- puts
74
- print colored_for(test_runner.result, message)
90
+ unless @fast_fail
91
+ runner.test_results.each do |suite, tests|
92
+ tests.each do |test, test_runner|
93
+ if message = message_for(test_runner)
94
+ puts
95
+ print colored_for(test_runner.result, message)
96
+ end
75
97
  end
76
98
  end
77
99
  end
@@ -177,6 +199,11 @@ module MiniTest
177
199
  '%d tests, %d assertions, %d failures, %d errors, %d skips' %
178
200
  [runner.test_count, runner.assertion_count, runner.failures, runner.errors, runner.skips]
179
201
  end
202
+
203
+ def print_info(e)
204
+ e.message.each_line { |line| print_with_info_padding(line) }
205
+ filter_backtrace(e.backtrace).each { |line| print_with_info_padding(line) }
206
+ end
180
207
  end
181
208
  end
182
209
  end
@@ -11,11 +11,7 @@ module MiniTest
11
11
  class SpecReporter
12
12
  include Reporter
13
13
  include ANSI::Code
14
-
15
- TEST_PADDING = 2
16
- TEST_SIZE = 63
17
- MARK_SIZE = 5
18
- INFO_PADDING = 8
14
+ include RelativePosition
19
15
 
20
16
  def before_suites(suites, type)
21
17
  puts 'Started'
@@ -80,22 +76,10 @@ module MiniTest
80
76
  end
81
77
 
82
78
  def print_info(e)
83
- e.message.each_line { |line| puts pad(line, INFO_PADDING) }
79
+ e.message.each_line { |line| print_with_info_padding(line) }
84
80
 
85
81
  trace = filter_backtrace(e.backtrace)
86
- trace.each { |line| puts pad(line, INFO_PADDING) }
87
- end
88
-
89
- def pad(str, size)
90
- ' ' * size + str
91
- end
92
-
93
- def pad_mark(str)
94
- "%#{MARK_SIZE}s" % str
95
- end
96
-
97
- def pad_test(str)
98
- pad("%-#{TEST_SIZE}s" % str, TEST_PADDING)
82
+ trace.each { |line| print_with_info_padding(line) }
99
83
  end
100
84
  end
101
85
  end
@@ -1,5 +1,5 @@
1
1
  module MiniTest
2
2
  module Reporters
3
- VERSION = "0.13.1"
3
+ VERSION = "0.14.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-reporters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-03 00:00:00.000000000 Z
12
+ date: 2012-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -129,6 +129,7 @@ files:
129
129
  - Rakefile
130
130
  - lib/minitest/before_test_hook.rb
131
131
  - lib/minitest/extensible_backtrace_filter.rb
132
+ - lib/minitest/relative_position.rb
132
133
  - lib/minitest/reporter.rb
133
134
  - lib/minitest/reporter_runner.rb
134
135
  - lib/minitest/reporters.rb
@@ -162,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
163
  version: '0'
163
164
  segments:
164
165
  - 0
165
- hash: 4420314549053922835
166
+ hash: -807798255971397869
166
167
  required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  none: false
168
169
  requirements:
@@ -171,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
172
  version: '0'
172
173
  segments:
173
174
  - 0
174
- hash: 4420314549053922835
175
+ hash: -807798255971397869
175
176
  requirements: []
176
177
  rubyforge_project: minitest-reporters
177
178
  rubygems_version: 1.8.24