minitest-json-reporter 0.0.0 → 0.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: 39c766ab4aa14a645f35aeae637ae5e98f9db20ae174c27c9a86b79ac886ac1c
4
- data.tar.gz: c6aceecf0cd14f2035c849fcac034c529febba8bb7b92b67d32d60ecb663d969
3
+ metadata.gz: 81c254b178148457162fcd5d46d59b3b3b75388cd38c32e7f5036aabc8eef8a3
4
+ data.tar.gz: 1b219b7126a088a8d5ba03999f96247b4012ef1d2adace023524c26d2f4413d9
5
5
  SHA512:
6
- metadata.gz: 560a3fd9a9dcc3c35a1385439871ad9726c15314b0ddf776e008dd670e20bfe3fe53106e28ca9dc08d23fa6b65d8779874ba2d2f03a905d2e63e7a2f1075da8a
7
- data.tar.gz: 31dd4436b06f337c5d64e6797d13f897ca18db38c4572b8f444a17cc7b49fcb13e6977352780095ccbcfecb5d77f3bec0aa3aa0859aecbf49c9e9ca0ed4ef206
6
+ metadata.gz: 987a6537daa03f60adee1a2ab81ea76d299efbc7bd4625ae3d1ebc4fdd379c2ca281eff3c738c6114107dfd6772a3776575180b333da7a14b6df1e3cc40327fe
7
+ data.tar.gz: 95b304b821cdfbfe665d0bf15a4cde5544e4e380d8b938919b06b5fbd1c70b07696e98a5aa742a0ad53bfc3f779123865d3dd06445c1eb8053349cb68398c0aa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-json-reporter (0.0.0)
4
+ minitest-json-reporter (0.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -41,6 +41,7 @@ GEM
41
41
 
42
42
  PLATFORMS
43
43
  x86_64-darwin-21
44
+ x86_64-linux
44
45
 
45
46
  DEPENDENCIES
46
47
  debug (~> 1.6.2)
data/Rakefile CHANGED
@@ -9,8 +9,4 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.test_files = FileList["test/**/test_*.rb"]
10
10
  end
11
11
 
12
- require "rubocop/rake_task"
13
-
14
- RuboCop::RakeTask.new
15
-
16
- task default: %i[test rubocop]
12
+ task default: %i[test]
@@ -1,20 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "minitest"
3
4
  require "json"
4
5
 
5
6
  module Minitest
7
+ def self.plugin_json_reporter_init(options)
8
+ if options[:json]
9
+ Minitest.reporter.reporters.clear
10
+ Minitest.reporter << JsonReporter.new(options)
11
+ end
12
+ end
13
+
14
+ def self.plugin_json_reporter_options(opts, options)
15
+ opts.on("--json", "Json dump") { |_json| options[:json] = true }
16
+ end
17
+
6
18
  class JsonReporter < AbstractReporter
7
- def start
19
+ attr_accessor :io, :results
20
+
21
+ def initialize(options)
22
+ @io = options[:io]
23
+ @results = []
8
24
  end
9
25
 
10
- def record
26
+ def record(result)
27
+ line = result.source_location[-1]
28
+ failure = result.failures[0]
29
+
30
+ if failure
31
+ # "/Users/marcusheng/projects/rails/budgetyourtime/test/models/user_test.rb:11"
32
+ line = failure.location.split("/")[-1].split(":")[-1]
33
+ end
34
+
35
+ results << {
36
+ name: result.name,
37
+ status: result.passed? ? "PASS" : "FAIL",
38
+ failures: failure.to_s,
39
+ line: line.to_i
40
+ }.to_json
11
41
  end
12
42
 
13
43
  def report
14
- super
15
-
16
- json_report = { test: "name of the test" }
17
- io.write(JSON.dump(json_report))
44
+ results.each { |result| io.puts result }
18
45
  end
19
46
  end
20
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-json-reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wei Zhe Heng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-24 00:00:00.000000000 Z
11
+ date: 2022-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debug