minitest-reporters-json_reporter 0.9.5 → 0.9.12

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: 637cb5c4cf030085c3cf5ea997be1ebb130de915
4
- data.tar.gz: 4aab5a9632c88573f94b1a8daf1cd3388e667662
3
+ metadata.gz: e0789166d0fc2d9eb234eea4ce73bd63c29777f8
4
+ data.tar.gz: c746180dbe9a3389819b6eee0f5f36cea99a119c
5
5
  SHA512:
6
- metadata.gz: 2da26b20f88627614a9a142ba19cc8a2a45844342d6c1bdfef840c27bdfd0ff29a81ca0aaa5572c6ac5e0d7cf73e5c7f826ffcd07b2c2bf097f2e2b566029096
7
- data.tar.gz: 7700f3b089c870d03f72e4c5891789bf00f5ea8f551a5fd1794075287e6796b1be4178743ccd95401b760190ea6adf7a113ecccfc04d8d6f31d0696450509307
6
+ metadata.gz: 7ddb553f9d9e94b239e5d6655c03b34a27590119b40294b85f036e33149b9329771d8f0f1ed4adf70e70bffcbfe2fce1a85e20e9d34dc802508af2f6e3deb868
7
+ data.tar.gz: 7c870a868a1f3badf3c5e1f703efb61e9bbb6dc4bf229d3d5bd5734356a20e8679c56cd08c186feb3f898c9df43c7c004a2946fbd4c9220a610be3e39a1e4629
data/.codeclimate.yml ADDED
@@ -0,0 +1,28 @@
1
+ # codeclimate.yml
2
+ engines:
3
+ rubocop:
4
+ enabled: true
5
+ #checks:
6
+ # Rubocop/Metrics/ClassLength:
7
+ # enabled: false
8
+ brakeman:
9
+ enabled: true
10
+ #exclude_fingerprints:
11
+ #- 08c185b3f764f262539a1f76997d3a89
12
+ duplication:
13
+ enabled: true
14
+ config:
15
+ languages:
16
+ - ruby
17
+ #mass_threshold: 30
18
+ ratings:
19
+ paths:
20
+ - app/**
21
+ - lib/**
22
+ - "**.rb"
23
+ - "**.go"
24
+ exclude_paths:
25
+ - spec/**/*
26
+ - "**/vendor/**/*"
27
+ - "**/docs/**/*"
28
+
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
+ /test/coverage/
6
7
  /pkg/
7
8
  /spec/reports/
8
9
  /tmp/
data/.travis.yml CHANGED
@@ -7,3 +7,13 @@ rvm:
7
7
  #- 1.9.3
8
8
  #- jruby-19mode
9
9
  #- rbx-2
10
+
11
+
12
+ notifications:
13
+ email:
14
+ recipients:
15
+ - ed.howland@gmail.com
16
+
17
+ on_success: always
18
+ on_failure: always
19
+
data/Develop.md ADDED
@@ -0,0 +1,11 @@
1
+ # Develop
2
+
3
+ A place to put development resources.
4
+
5
+ ## Resources
6
+
7
+ ### Links
8
+
9
+ [Coveralls](https://coveralls.io/github/edhowland/minitest-reporters-json_reporter)
10
+ Where this repo is listed on the Coveralls repo page for coverage statistics, trends, etc.
11
+
data/Gemfile CHANGED
@@ -5,5 +5,5 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem 'minitest-reporters', '~> 1.1.8'
8
+ gem 'coveralls', require: false
8
9
  end
9
-
data/README.md CHANGED
@@ -2,19 +2,26 @@
2
2
 
3
3
  This is an extension gem for the minitest-reporters gem. It adds JSON output as an output format.
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/minitest-reporters-json_reporter.svg)][gem]
5
+ [![Gem Version](https://badge.fury.io/rb/minitest-reporters-json_reporter.svg)](https://badge.fury.io/rb/minitest-reporters-json_reporter)
6
6
  [![Build Status](https://travis-ci.org/edhowland/minitest-reporters-json_reporter.png?branch=master)](https://travis-ci.org/edhowland/minitest-reporters-json_reporter)
7
-
7
+ [![Coverage Status](https://coveralls.io/repos/github/edhowland/minitest-reporters-json_reporter/badge.svg?branch=master)](https://coveralls.io/github/edhowland/minitest-reporters-json_reporter?branch=master)
8
+ [![Code Climate](https://codeclimate.com/github/edhowland/minitest-reporters-json_reporter/badges/gpa.svg)](https://codeclimate.com/github/edhowland/minitest-reporters-json_reporter)
9
+ [![Inline docs](http://inch-ci.org/github/edhowland/minitest-reporters-json_reporter.svg?style=shields)](http://inch-ci.org/github/edhowland/minitest-reporters-json_reporter)
8
10
 
9
11
 
10
12
  ## Abstract
11
13
 
12
14
  You can use this gem to interface Minitest output into automated tools like CI, CD or IDEs or code editors. An
13
15
  example interface might be to the Atom editor: [https://atom.io](https://atom.io)
16
+
17
+ Use of JSON as a format for test runs opens up possibilities for different types of analysis.
18
+ You can organize the output based on elapsed time or number of assertions of tests, for example.
19
+ See the 'jq sort' example below.
20
+
14
21
  I originally wrote this gem to interface to the Viper audible code editor for the blind community. See: [https://github.com/edhowland/viper](https://github.com/edhowland/viper)
15
22
  Using this gem with Viper also requires the 'viper_ruby' package. See [https://github.com/edhowland/viper_ruby](https://github.com/edhowland/viper_ruby)
16
23
 
17
- ## Version 0.9.5
24
+ ## Version 0.9.12
18
25
 
19
26
  ## Installation
20
27
 
@@ -117,7 +124,7 @@ $ ruby report_spec.rb | jq .
117
124
  "status": { "code": "Failed", "color": "red" },
118
125
  "metadata": {
119
126
  "generated_by": "Minitest::Reporters::JsonReporter",
120
- "version": "0.9.5",
127
+ "version": "0.9.12",
121
128
  "ruby_version": "2.2.2",
122
129
  "ruby_patchlevel": 95,
123
130
  "ruby_platform": "x86_64-linux",
@@ -182,6 +189,59 @@ $ ruby report_spec.rb | jq .
182
189
 
183
190
  ```
184
191
 
192
+ ## Example analysis feedback
193
+
194
+ JSON can be parsed and manipulated to provide many types of useful information.
195
+ Below are some example usages.
196
+ We use the 'jq' program to parse and select and arrange the output.
197
+ The version of 'jq' is 1.5. It can be downloaded/install instructions here: [Download JQ](https://stedolan.github.io/jq/download/)
198
+ See: [JQ Developer Manual](https://stedolan.github.io/jq/manual/)
199
+
200
+
201
+
202
+ ### Sort by time, slowest first
203
+
204
+ This sort would show you the slowest tests first, getting faster further down the array.
205
+ Similar to Minitest::Reporters::MeanTimeReporter which produces a report summary showing the slowest running tests.
206
+
207
+
208
+ ```
209
+ $ ruby timings_spec.rb --verbose | jq '.passes | sort_by(.time) | reverse[] | .name, .time'
210
+ "test_0001_should be slow"
211
+ 5.001584862009622
212
+ "test_0003_should be slightly faster"
213
+ 1.0003409570199437
214
+ "test_0002_should be fast"
215
+ 2.9060000088065863e-05
216
+ ```
217
+
218
+ ### Group By Class example
219
+
220
+ Minitest usually runs your tests in a random sequence. This is
221
+ great for test isolation and to check for state bleed-thru, but can be annoying if trying
222
+ to determine where similar tests are failing. You can use the jq 'sort_by' or 'group_by' filters to get them back in
223
+ some semblace of order.
224
+
225
+ Here we group the .fails[] array by their class name. (The file: 'group_by_spec.rb'
226
+ contains 4 tests inside 2 classes.)
227
+
228
+ ```
229
+ $ ruby group_by_spec.rb |jq '.fails | group_by(.class) | flatten[] | .class, .name'
230
+ "TestNumericalGroup"
231
+ "test_4_times_6_equals_24"
232
+ "TestNumericalGroup"
233
+ "test_positive_integers_are_greater_than_0"
234
+ "TestStringGroup"
235
+ "test_string_is_hello_world"
236
+ "TestStringGroup"
237
+ "test_value_length_equals_2"
238
+ ```
239
+
240
+ Note the above result is an array of 2 arrays grouped by the .class key.
241
+
242
+
243
+
244
+
185
245
  ## Customizing the JSON format
186
246
 
187
247
  You can adjust the contents of the returned JSON by sub-classing the Minitest::Reporters::JsonReporter class.
@@ -221,7 +281,7 @@ Note: Extra credit if git flow feature branching was used.
221
281
 
222
282
  * Code: [https://github.com/edhowland/minitest-reporters-json_reporter](https://github.com/edhowland/minitest-reporters-json_reporter)
223
283
  * Bugs: [https://github.com/edhowland/minitest-reporters-json_reporter/issues](https://github.com/edhowland/minitest-reporters-json_reporter/issues)
224
- * Docs: [http://www.rubydoc.info/gems/minitest-reporters-json_reporter/0.9.5](http://www.rubydoc.info/gems/minitest-reporters-json_reporter/0.9.5)
284
+ * Docs: [http://www.rubydoc.info/gems/minitest-reporters-json_reporter/0.9.12](http://www.rubydoc.info/gems/minitest-reporters-json_reporter/0.9.5)
225
285
  * Gem: [https://rubygems.org/gems/minitest-reporters-json_reporter](https://rubygems.org/gems/minitest-reporters-json_reporter)
226
286
 
227
287
  ###### Feedback
data/Rakefile CHANGED
@@ -11,4 +11,4 @@ task :yard do
11
11
  sh 'yardoc -o ./doc'
12
12
  end
13
13
 
14
- task :default => [:test]
14
+ task default: [:test]
@@ -8,7 +8,7 @@ module Minitest
8
8
  class JsonReporter < BaseReporter
9
9
  ##
10
10
  # Version of the Minitest::Reporters::JsonReporter gem.
11
- VERSION = '0.9.5'.freeze
11
+ VERSION = '0.9.12'.freeze
12
12
  end
13
13
  end
14
14
  end
@@ -67,6 +67,8 @@ module Minitest
67
67
  h
68
68
  end
69
69
 
70
+ ##
71
+ # Returns the statushash portion of the output.
70
72
  def status_h
71
73
  {
72
74
  code: ['Failed', 'Passed with skipped tests', 'Success'][color_i],
@@ -98,6 +100,8 @@ module Minitest
98
100
  end
99
101
  end
100
102
 
103
+ ##
104
+ # Returns the metadata hash portion of the output.
101
105
  def metadata_h
102
106
  {
103
107
  generated_by: self.class.name,
@@ -110,6 +114,9 @@ module Minitest
110
114
  }
111
115
  end
112
116
 
117
+ ##
118
+ # Transforms the options hash part of the metadata object to represent the
119
+ # 'io' object as the string 'STDOUT' if it is $stdout.
113
120
  def transform(opts)
114
121
  o = opts.clone
115
122
  o[:io] = o[:io].class.name
@@ -117,6 +124,8 @@ module Minitest
117
124
  o
118
125
  end
119
126
 
127
+ ##
128
+ # Returns the statistics hash object as part of the output.
120
129
  def statistics_h
121
130
  {
122
131
  total: count,
@@ -128,6 +137,8 @@ module Minitest
128
137
  }
129
138
  end
130
139
 
140
+ ##
141
+ # Returns the timings hash object as part of the output.
131
142
  def timings_h
132
143
  {
133
144
  total_seconds: total_time,
@@ -136,11 +147,16 @@ module Minitest
136
147
  }
137
148
  end
138
149
 
150
+ ##
151
+ # Returns the fails array of failure or error hash objects as part of
152
+ # the output.
139
153
  def failures_h
140
154
  tests.reject { |e| e.skipped? || e.passed? || e.failure.nil? }
141
155
  .map { |e| failure_h(e) }
142
156
  end
143
157
 
158
+ ##
159
+ # Returns either a failed_h or error_h given a result (test).
144
160
  def failure_h(result)
145
161
  if result.error?
146
162
  error_h(result)
@@ -149,6 +165,9 @@ module Minitest
149
165
  end
150
166
  end
151
167
 
168
+ ##
169
+ # Returns the error hash object given a result (test) as part of the
170
+ # fails[] array.
152
171
  def error_h(result)
153
172
  h = result_h(result, 'error')
154
173
  h[:message] = result.failure.message
@@ -157,6 +176,8 @@ module Minitest
157
176
  h
158
177
  end
159
178
 
179
+ ##
180
+ # Returns the failure hash object given a result (test).
160
181
  def failed_h(result)
161
182
  h = result_h(result, 'failed')
162
183
  h[:message] = result.failure.message
@@ -164,10 +185,14 @@ module Minitest
164
185
  h
165
186
  end
166
187
 
188
+ ##
189
+ # Returns the skips[] array object as part of the output.
167
190
  def skips_h
168
191
  tests.select(&:skipped?).map { |e| skip_h(e) }
169
192
  end
170
193
 
194
+ ##
195
+ # Returns the formatted skip hash object given a result (test).
171
196
  def skip_h(result)
172
197
  h = result_h(result, 'skipped')
173
198
  h[:message] = result.failure.message
@@ -175,10 +200,16 @@ module Minitest
175
200
  h
176
201
  end
177
202
 
203
+ ##
204
+ # Returns the passes[] array object as part of the output.
178
205
  def passes_h
179
206
  tests.select(&:passed?).map { |e| result_h(e, 'passed') }
180
207
  end
181
208
 
209
+ ##
210
+ # Returns the common part of a result hash.
211
+ # Given a type string and a result (test).
212
+ # Includes the type, the class, the name and the time of the result.
182
213
  def result_h(result, type)
183
214
  {
184
215
  type: type,
@@ -189,6 +220,9 @@ module Minitest
189
220
  }
190
221
  end
191
222
 
223
+ ##
224
+ # Returns the location (pathname:line_number) of the line that produced
225
+ # the failure or error.
192
226
  def location(exception)
193
227
  last_before_assertion = ''
194
228
 
@@ -2,11 +2,10 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
-
6
5
  # Must hard code the exact version number because of circular dependency
7
6
  Gem::Specification.new do |spec|
8
7
  spec.name = 'minitest-reporters-json_reporter'
9
- spec.version = '0.9.5'
8
+ spec.version = '0.9.12'
10
9
  spec.authors = ['edhowland']
11
10
  spec.email = ['ed.howland@gmail.com']
12
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-reporters-json_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - edhowland
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest-reporters
@@ -67,12 +67,15 @@ executables: []
67
67
  extensions: []
68
68
  extra_rdoc_files: []
69
69
  files:
70
+ - ".codeclimate.yml"
71
+ - ".coveralls.yml"
70
72
  - ".gitignore"
71
73
  - ".rubocop.yml"
72
74
  - ".travis.yml"
73
75
  - Announcement.txt
74
76
  - CODE_OF_CONDUCT.md
75
77
  - CONTRIBUTING.md
78
+ - Develop.md
76
79
  - Gemfile
77
80
  - LICENSE.txt
78
81
  - README.md