Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect the IO option #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/minitest/reporters/json_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ module Reporters
# Minitest Reporter that produces a JSON output for interface in
# IDEs, CD/CI tools and codeeditors
class JsonReporter < BaseReporter
attr_accessor :output

##
# Constructor for Minitest::Reporters::JsonReporter
# Takes possible options. E.g. :verbose => true
def initialize(options = {})
super

self.output = options[:io] unless options[:io].nil?
end

##
Expand All @@ -34,7 +38,11 @@ def report

@storage = to_h
# formate @storage as JSON and write to output stream
io.write(JSON.dump(@storage))
if output.nil?
io.write(JSON.dump(@storage))
else
output.write(JSON.dump(@storage))
end
end

protected
Expand Down