minitest-reporters-ordered_spec_reporter 1.0.0 → 1.1.0

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
  SHA256:
3
- metadata.gz: 25c760836001c888fe6b9d019c89ab55a013b4ec3bd5f206ff2980f0fe9a50d4
4
- data.tar.gz: ac4fa196c41b0c98f963c3e11c90e9f8abdca8462a2ba0e94f3dfc3702fede39
3
+ metadata.gz: ed71e90717676ce09625103d4785f2e0705bcc7218eb800794fe95a54d074a4c
4
+ data.tar.gz: 9a0a25859f339ada0bad3119369cf11c0278362d124801cc5ce5b3e81cd48cad
5
5
  SHA512:
6
- metadata.gz: 13c5595cb6611454d13a8c9ff11b4dbb906d656562a799213022f3ada6b696031fe5678833dfa79885bfab439630e82186b722d757f06bdbe0cc574d2d4ff946
7
- data.tar.gz: 7bc0c90cb39390e248ceb88be4692204190cd62da2f44cf5e61ff04549a1ba3e0ce837f96b120cd0215d24a675e864e938d2591d560f5a9df22bf70447886404
6
+ metadata.gz: 18db9ba2d826671a4b7b34189ff410e9b2169d244b1d5bc162fd720b5f3987891b3e48b97759c498971517d43ffe46b592bf55a094e420b0073ccd0ae4a90091
7
+ data.tar.gz: f0eb84a746fb49c927105c816d4e42fe03471766cff0aab711296863d4ecb6266f2b6c94485ec34c5d0bf3291f3577ddf92158289145beb06040ebb5d48f73f0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-reporters-ordered_spec_reporter (1.0.0)
4
+ minitest-reporters-ordered_spec_reporter (1.1.0)
5
5
  minitest-reporters (~> 1.3.6)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Modified version of `Minitest::Reporters::SpecReporter` which prints test results in alphabetical order, grouped by test class.
4
4
 
5
- This gem makes use of the 'minitest-reporters' library. It modifies the test reporting order, but not Minitest's randomized test execution order.
5
+ This gem makes use of the `minitest-reporters` library. It modifies the test reporting order, but not Minitest's randomized test execution order.
6
6
 
7
7
  ## Installation
8
8
 
@@ -36,4 +36,6 @@ The constructor accepts the following options:
36
36
  |-|-|-|
37
37
  | `:indentation` | number of indentations to apply to top level test class reports | `0` |
38
38
  | `:spaces` | number of spaces per indentation level | `2` |
39
- | `:truncate` | whether to remove the `test_####_` prefix from each test name | `true` |
39
+ | `:justification` | width of the test description column | `65` (aligns with default `SpecReporter`)|
40
+ | `:truncate` | whether to remove the `test_####_` prefix from each test name | `false` |
41
+ | `:loose` | whether to add a blank line after each group of tests | `false` |
@@ -7,11 +7,16 @@ module Minitest
7
7
  include ANSI::Code
8
8
  include RelativePosition
9
9
 
10
+ @@default_options = {
11
+ indentation: 0,
12
+ spaces: 2,
13
+ justification: TEST_SIZE + TEST_PADDING, # match output of SpecReporter
14
+ truncate: false,
15
+ loose: false,
16
+ }
17
+
10
18
  def initialize options = {}
11
- super
12
- @indentation = options[:indentation] || 0
13
- @spaces = options[:spaces] || 2
14
- @truncate = options[:truncate] || true
19
+ super(@@default_options.merge(options))
15
20
  end
16
21
 
17
22
  def start
@@ -36,8 +41,8 @@ module Minitest
36
41
  end
37
42
 
38
43
  tree.sort.to_h.each { |k, v| print_suite(k, v) }
39
-
40
- puts
44
+
45
+ puts unless options[:loose] # already printed by last suite if true
41
46
  puts('Finished in %.5fs' % total_time)
42
47
  print('%d tests, %d assertions, ' % [count, assertions])
43
48
  color = failures.zero? && errors.zero? ? :green : :red
@@ -48,31 +53,32 @@ module Minitest
48
53
 
49
54
  protected
50
55
 
51
- def print_suite(name, branch, indentation = @indentation)
52
- branch = branch.sort.to_h
53
- puts ' ' * indentation * @spaces + name unless name.nil?
56
+ def print_suite(name, branch, indentation = options[:indentation])
57
+ puts pad_string(name, indentation) unless name.nil?
54
58
 
55
- (branch[:tests] || []).each do |test|
56
- print ' ' * indentation * @spaces
57
- print_test(test)
58
- end
59
+ indentation += 1
59
60
 
60
- branch.each do |k, v|
61
- print_suite k, v, indentation + 1 unless k == :tests
61
+ if branch[:tests]
62
+ branch[:tests].each do |test|
63
+ print_test(test, indentation)
64
+ end
65
+ puts if options[:loose]
62
66
  end
63
67
 
64
- puts if indentation == 0
68
+ branch.sort.to_h.each do |k, v|
69
+ print_suite k, v, indentation unless k == :tests
70
+ end
65
71
  end
66
72
 
67
- def print_test(test)
68
- record_print_status(test)
73
+ def print_test(test, indentation)
74
+ record_print_status(test, indentation)
69
75
  record_print_failures_if_any(test)
70
76
  end
71
77
 
72
- def record_print_status(test)
78
+ def record_print_status(test, indentation)
73
79
  test_name = test.name.gsub(/^test_: /, 'test:')
74
- test_name = test_name.gsub(/^test_\d*_/, '') if @truncate
75
- print pad_test(test_name)
80
+ test_name = test_name.gsub(/^test_\d*_/, '') if options[:truncate]
81
+ print pad_string(test_name, indentation)
76
82
  print_colored_status(test)
77
83
  print(" (%.2fs)" % test.time) unless test.time.nil?
78
84
  puts
@@ -84,6 +90,10 @@ module Minitest
84
90
  puts
85
91
  end
86
92
  end
93
+
94
+ def pad_string(str, indentation)
95
+ (' ' * indentation * options[:spaces] + str).ljust(options[:justification])
96
+ end
87
97
  end
88
98
  end
89
99
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "minitest-reporters-ordered_spec_reporter"
7
- spec.version = "1.0.0"
7
+ spec.version = "1.1.0"
8
8
  spec.authors = ["Nick Barry"]
9
9
  spec.email = ["itsnickbarry@protonmail.ch"]
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-reporters-ordered_spec_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-03 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler