minitest-utils 0.1.2 → 0.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: 700f67bcfb5d5fe53a2a75b7bf3ec8843ccc82f9
4
- data.tar.gz: 9d5ad7d010ddc713d2ee5e420e93ccd3a9afec0c
3
+ metadata.gz: a3d7eacdc6f99419e24d644628d2ce2bd8b034b5
4
+ data.tar.gz: c2640e2eaf4dad798ad8ce8f329214ced19cf523
5
5
  SHA512:
6
- metadata.gz: caf2e42d4875292a0bb788cefce0f9ea3d3cbe76925250401c1e84e7b236bf572158e6b1b5d03c87ad7e53e55ff53b16173be74823295bc562899312fe9cebea
7
- data.tar.gz: 0b1ea576e5cabae344f583f8a623164a299f1b6024c6889f37bccad16705e68c62563ea08628fce6ed610a678d328f0b8d6e5bbf47096d0e7541f1ec8bbbb58f
6
+ metadata.gz: 7fb4411e84f444f31511a7a5be6329c3c2d6433cc763bedcf40250c0c66fc96ba9fecb338fec078127d5ec2644645e9e6752967eb0b60135c08d1e2bb703a41e
7
+ data.tar.gz: 05e09091d4f8826a3d193c651f1be8b9cbc03c5860cac8324a1b2311c9ec6ae224e71b27ff67a6372cf1fad9b0ab8f28479a0ebe4bc97597f45d373d37f96121
@@ -1,8 +1,22 @@
1
1
  module Minitest
2
2
  module Utils
3
3
  class Reporter < Minitest::StatisticsReporter
4
+ COLOR_FOR_RESULT_CODE = {
5
+ '.' => :green,
6
+ 'E' => :red,
7
+ 'F' => :red,
8
+ 'S' => :yellow
9
+ }
10
+
11
+ COLOR = {
12
+ red: 31,
13
+ green: 32,
14
+ yellow: 33,
15
+ blue: 34
16
+ }
17
+
4
18
  def statistics
5
- stats = super
19
+ super
6
20
  end
7
21
 
8
22
  def record(result)
@@ -89,7 +103,7 @@ module Minitest
89
103
 
90
104
  def find_test_file(result)
91
105
  filter_backtrace(result.failure.backtrace)
92
- .find {|line| line.match(%r(^(test|spec)/.*?_(test|spec).rb)) }
106
+ .find {|line| line.match(%r((test|spec)/.*?_(test|spec).rb)) }
93
107
  .gsub(/:\d+.*?$/, '')
94
108
  end
95
109
 
@@ -113,40 +127,18 @@ module Minitest
113
127
 
114
128
  def result_name(name)
115
129
  name
116
- .gsub(/^test_\d+_/, '')
130
+ .gsub(/^test(_\d+)?_/, '')
117
131
  .gsub(/_/, ' ')
118
132
  end
119
133
 
120
134
  def print_result_code(result_code)
121
- result_code = case result_code
122
- when '.'
123
- color('.', :green)
124
- when 'S'
125
- color('S', :yellow)
126
- when 'F'
127
- color('F', :red)
128
- when 'E'
129
- color('E', :red)
130
- else
131
- color(result_code)
132
- end
133
-
135
+ result_code = color(result_code, COLOR_FOR_RESULT_CODE[result_code])
134
136
  io.print result_code
135
137
  end
136
138
 
137
139
  def color(string, color = :default)
138
- case color
139
- when :red
140
- "\e[31m#{string}\e[0m"
141
- when :green
142
- "\e[32m#{string}\e[0m"
143
- when :yellow
144
- "\e[33m#{string}\e[0m"
145
- when :blue
146
- "\e[34m#{string}\e[0m"
147
- else
148
- "\e[0m#{string}"
149
- end
140
+ color = COLOR.fetch(color, 0)
141
+ "\e[#{color}m#{string}"
150
142
  end
151
143
 
152
144
  def pluralize(word, count)
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Utils
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-08 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest