minitest-json-reporter 0.0.1 → 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: 72684c68b0ffdd75f170b1ccf36cd31eb95b14bb832835705e96ec1cfe9ef69d
4
- data.tar.gz: 549b0db1ccc91b5b5fa15eeeedda3c26f38d006d29d1226ffb36c5f380cd7937
3
+ metadata.gz: 81c254b178148457162fcd5d46d59b3b3b75388cd38c32e7f5036aabc8eef8a3
4
+ data.tar.gz: 1b219b7126a088a8d5ba03999f96247b4012ef1d2adace023524c26d2f4413d9
5
5
  SHA512:
6
- metadata.gz: 73af481d892d42e21ee52be71f3fad54ca9a4beee0db8b4f268ba8de815e7aea39b7deb02edc87bebec1060599b6748cf1d5f8839a27ed7e84682d7058ba7d21
7
- data.tar.gz: f183ee759aee814bd5d09d9d97f70496daefa9c57415be7e69589950c8aa5fff848458fdbf4e035bcfbc456703a2aac13538b60b7f6e10f50f4748504cb624dd
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]
@@ -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.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.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