minitest-reporters 1.1.2 → 1.1.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: 846ef0a08df37769401f230f5de0ecbb833eef54
4
- data.tar.gz: 1fd0f582c07365a9524cfd5bfe2462f62fbe67a6
3
+ metadata.gz: a9c9e2598ba34e48a68673e2bfdbab2b63bcdf85
4
+ data.tar.gz: 48fe15b97bea95c41f7cc2921fa6c8d0412e4a37
5
5
  SHA512:
6
- metadata.gz: 3ca327e55a81401732fe28cd64b67e7a03e1a4242714556465bed2e9302e95f6c44bbbcc05772bc266e163138913e11f8b039c55e1ea24f8b070db34c33bf219
7
- data.tar.gz: 2e765106869fb020d41269e54f170649d3ddc6e657e9f597e429281018ccdb8650ed732911378213d7d9d583318de29b83ca1621a5cf04f97bdfd5bcd9ddc732
6
+ metadata.gz: b564d9f76facdc1f990ebc5a1c18a5af0b8506b8cc6a6e15220c0e2c7340348f663cc10943de96f0ab56e10eec3898025f836099a08e425aa7674c978c425580
7
+ data.tar.gz: 8cc758211dd597018fb8d58fdffadcd063145e921b18015c1e5f58d9d8696c3eded2d48afb7e7cf3b6703ec4ad83386c5645adc34013e77aa5e07a9a9c443085
data/.gitignore CHANGED
@@ -4,6 +4,7 @@ pkg
4
4
  test/tmp
5
5
  test/version_tmp
6
6
  test/reports
7
+ test/html_reports
7
8
  tmp
8
9
  pkg
9
10
  *.gem
@@ -16,6 +16,7 @@ module Minitest
16
16
  autoload :RubyMineReporter, "minitest/reporters/rubymine_reporter"
17
17
  autoload :JUnitReporter, "minitest/reporters/junit_reporter"
18
18
  autoload :HtmlReporter, "minitest/reporters/html_reporter"
19
+ autoload :MeanTimeReporter, "minitest/reporters/mean_time_reporter"
19
20
 
20
21
  class << self
21
22
  attr_accessor :reporters
@@ -52,14 +52,16 @@ module Minitest
52
52
  # :reports_dir - the directory the reports should be written to, defaults to 'test/html_reports'
53
53
  # :erb_template - the path to a custom ERB template, defaults to the supplied ERB template
54
54
  # :mode - Useful for debugging, :terse suppresses errors and is the default, :verbose lets errors bubble up
55
+ # :output_filename - the report's filename, defaults to 'index.html'
55
56
  def initialize(args = {})
56
57
  super({})
57
58
 
58
59
  defaults = {
59
- :title => 'Test Results',
60
- :erb_template => "#{File.dirname(__FILE__)}/../templates/index.html.erb",
61
- :reports_dir => 'test/html_reports',
62
- :mode => :safe
60
+ :title => 'Test Results',
61
+ :erb_template => "#{File.dirname(__FILE__)}/../templates/index.html.erb",
62
+ :reports_dir => 'test/html_reports',
63
+ :mode => :safe,
64
+ :output_filename => 'index.html'
63
65
  }
64
66
 
65
67
  settings = defaults.merge(args)
@@ -67,6 +69,7 @@ module Minitest
67
69
  @mode = settings[:mode]
68
70
  @title = settings[:title]
69
71
  @erb_template = settings[:erb_template]
72
+ @output_filename = settings[:output_filename]
70
73
  reports_dir = settings[:reports_dir]
71
74
 
72
75
  @reports_path = File.absolute_path(reports_dir)
@@ -82,7 +85,7 @@ module Minitest
82
85
 
83
86
  begin
84
87
  puts "Writing HTML reports to #{@reports_path}"
85
- html_file = @reports_path + "/index.html"
88
+ html_file = "#{@reports_path}/#{@output_filename}"
86
89
  erb_str = File.read(@erb_template)
87
90
  renderer = ERB.new(erb_str)
88
91
 
@@ -94,7 +94,7 @@ module Minitest
94
94
  # run.
95
95
  def defaults
96
96
  {
97
- count: 15,
97
+ show_count: 15,
98
98
  previous_runs_filename: '/tmp/minitest_reporters_previous_run',
99
99
  report_filename: '/tmp/minitest_reporters_report',
100
100
  }
@@ -119,10 +119,14 @@ module Minitest
119
119
  avg = (sum / size).round(9).to_s.ljust(12)
120
120
  min = Array(timings).min.to_s.ljust(12)
121
121
  max = Array(timings).max.to_s.ljust(12)
122
+ run = Array(timings).last.to_s.ljust(12)
123
+
124
+ rating = rate(run, min, max)
122
125
 
123
126
  obj << "#{avg_label} #{avg} " \
124
127
  "#{min_label} #{min} " \
125
128
  "#{max_label} #{max} " \
129
+ "#{run_label(rating)} #{run} " \
126
130
  "#{des_label} #{description}\n"
127
131
  end.sort.reverse.join
128
132
  end
@@ -134,8 +138,8 @@ module Minitest
134
138
 
135
139
  # @return [Fixnum] The number of tests to output to output to the screen
136
140
  # after each run.
137
- def count
138
- options[:count]
141
+ def show_count
142
+ options[:show_count]
139
143
  end
140
144
 
141
145
  # @return [Hash<String => Array<Float>]
@@ -213,45 +217,75 @@ module Minitest
213
217
  # Creates a new report file in the 'report_filename'. This file contains
214
218
  # a line for each test of the following example format:
215
219
  #
216
- # Avg: 0.0555555 Min: 0.0498765 Max: 0.0612345 Description: The test name
220
+ # Avg: 0.0555555 Min: 0.0498765 Max: 0.0612345 Last: 0.0499421 Description: The test name
217
221
  #
218
222
  # Note however the timings are to 9 decimal places, and padded to 12
219
223
  # characters and each label is coloured, Avg (yellow), Min (green),
220
- # Max (red) and Description (blue). It looks pretty!
224
+ # Max (red), Last (multi), and Description (blue). It looks pretty!
225
+ #
226
+ # The 'Last' label is special in that it will be colour coded depending
227
+ # on whether the last run was faster (bright green) or slower (bright red)
228
+ # or inconclusive (purple). This helps to identify changes on a per run
229
+ # basis.
221
230
  #
222
231
  # @return [void]
223
232
  def create_new_report!
224
233
  File.write(report_filename, report_title + report_body)
225
234
  end
226
235
 
227
- # Writes a number of tests (configured via the 'count' option) to the
236
+ # Writes a number of tests (configured via the 'show_count' option) to the
228
237
  # screen after creating the report. See '#create_new_report!' for example
229
238
  # output information.
230
239
  #
231
240
  # @return [void]
232
241
  def write_to_screen!
233
242
  puts report_title
234
- puts report_body.lines.take(count)
243
+ puts report_body.lines.take(show_count)
235
244
  end
236
245
 
237
246
  # @return [String] A yellow 'Avg:' label.
238
247
  def avg_label
239
- "\e[33mAvg:\e[39m"
248
+ ANSI::Code.yellow('Avg:')
240
249
  end
241
250
 
242
251
  # @return [String] A blue 'Description:' label.
243
252
  def des_label
244
- "\e[34mDescription:\e[39m"
253
+ ANSI::Code.blue('Description:')
245
254
  end
246
255
 
247
256
  # @return [String] A red 'Max:' label.
248
257
  def max_label
249
- "\e[31mMax:\e[39m"
258
+ ANSI::Code.red('Max:')
250
259
  end
251
260
 
252
261
  # @return [String] A green 'Min:' label.
253
262
  def min_label
254
- "\e[32mMin:\e[39m"
263
+ ANSI::Code.green('Min:')
264
+ end
265
+
266
+ # @param rating [Symbol] One of :faster, :slower or :inconclusive.
267
+ # @return [String] A purple 'Last:' label.
268
+ def run_label(rating)
269
+ case rating
270
+ when :faster then ANSI::Code.green('Last:')
271
+ when :slower then ANSI::Code.red('Last:')
272
+ else
273
+ ANSI::Code.magenta('Last:')
274
+ end
275
+ end
276
+
277
+ # @param run [Float] The last run time.
278
+ # @param min [Float] The minimum run time.
279
+ # @param max [Float] The maximum run time.
280
+ # @return [Symbol] One of :faster, :slower or :inconclusive.
281
+ def rate(run, min, max)
282
+ if run == min
283
+ :faster
284
+ elsif run == max
285
+ :slower
286
+ else
287
+ :inconclusive
288
+ end
255
289
  end
256
290
 
257
291
  end
@@ -28,8 +28,8 @@ module Minitest
28
28
 
29
29
  def record(test)
30
30
  super
31
- test.name.gsub!(/^test_:/, 'test:')
32
- print pad_test(test.name)
31
+ test_name = test.name.gsub(/^test_: /, 'test:')
32
+ print pad_test(test_name)
33
33
  print_colored_status(test)
34
34
  print(" (%.2fs)" % test.time) unless test.time.nil?
35
35
  puts
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Reporters
3
- VERSION = '1.1.2'
3
+ VERSION = '1.1.3'
4
4
  end
5
5
  end
@@ -23,5 +23,19 @@ module MinitestReportersTest
23
23
  @reporter.record(@test)
24
24
  end
25
25
  end
26
+
27
+ def test_responds_to_test_name_after_record
28
+ test_name = 'test_: Should foo'
29
+ the_test_class = Class.new(Minitest::Test) do
30
+ define_method test_name do
31
+ assert(false)
32
+ end
33
+ end
34
+ the_test = the_test_class.new('')
35
+ the_test.name = test_name
36
+ @reporter.io = StringIO.new
37
+ @reporter.record(the_test)
38
+ assert_respond_to the_test, the_test.name
39
+ end
26
40
  end
27
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-reporters
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2015-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -164,23 +164,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project: minitest-reporters
167
- rubygems_version: 2.4.5
167
+ rubygems_version: 2.4.3
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Create customizable Minitest output formats
171
- test_files:
172
- - test/fixtures/junit_filename_bug_example_test.rb
173
- - test/fixtures/mean_time_test.rb
174
- - test/fixtures/progress_detailed_skip_test.rb
175
- - test/fixtures/progress_test.rb
176
- - test/fixtures/sample_test.rb
177
- - test/gallery/bad_test.rb
178
- - test/gallery/good_test.rb
179
- - test/integration/reporters/junit_reporter_test.rb
180
- - test/integration/reporters/mean_time_reporter_test.rb
181
- - test/integration/reporters/progress_reporter_test.rb
182
- - test/test_helper.rb
183
- - test/unit/minitest/extensible_backtrace_filter_test.rb
184
- - test/unit/minitest/reporters_test.rb
185
- - test/unit/minitest/spec_reporter_test.rb
186
- has_rdoc:
171
+ test_files: []