minitest-json-reporter 0.0.1 → 0.1.1

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: 72684c68b0ffdd75f170b1ccf36cd31eb95b14bb832835705e96ec1cfe9ef69d
4
- data.tar.gz: 549b0db1ccc91b5b5fa15eeeedda3c26f38d006d29d1226ffb36c5f380cd7937
3
+ metadata.gz: 32e529fecda5d209b7f4a7451ed87ac425b92cb0300ad463c37f6ab99d213f58
4
+ data.tar.gz: 42b7f08dce8f6f10c158a6588a6dcae306442a8a0f6639892a6ab47ffe26ea5e
5
5
  SHA512:
6
- metadata.gz: 73af481d892d42e21ee52be71f3fad54ca9a4beee0db8b4f268ba8de815e7aea39b7deb02edc87bebec1060599b6748cf1d5f8839a27ed7e84682d7058ba7d21
7
- data.tar.gz: f183ee759aee814bd5d09d9d97f70496daefa9c57415be7e69589950c8aa5fff848458fdbf4e035bcfbc456703a2aac13538b60b7f6e10f50f4748504cb624dd
6
+ metadata.gz: a24aad31b093e75bc1f259e00caaf57aa487571632aac5c7476b516df3d88ccd1060db5442397b773548b32c5566614191c553fe9579404c9baad13dfdad9ab2
7
+ data.tar.gz: 377ed8cbef48f871c8ef2bd82b763e5e943e242e2a3648b327314a75535ade7914f37f5fe7f0204bff735f5b39561332e5ecc5aefac13a1c6d95a69cac423e65
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.1.0)
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]
@@ -4,18 +4,44 @@ require "minitest"
4
4
  require "json"
5
5
 
6
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
+
7
18
  class JsonReporter < AbstractReporter
8
- def start
19
+ attr_accessor :io, :results
20
+
21
+ def initialize(options)
22
+ @io = options[:io]
23
+ @results = []
9
24
  end
10
25
 
11
- 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.error.to_s,
39
+ line: line.to_i
40
+ }.to_json
12
41
  end
13
42
 
14
43
  def report
15
- super
16
-
17
- json_report = { test: "name of the test" }
18
- io.write(JSON.dump(json_report))
44
+ results.each { |result| io.puts result }
19
45
  end
20
46
  end
21
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.1
4
+ version: 0.1.1
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