Skip to content

Commit f95fe1b

Browse files
committed
Fix json formatter tests
1 parent c238e0a commit f95fe1b

File tree

2 files changed

+250
-147
lines changed

2 files changed

+250
-147
lines changed

lib/rails_stats/json_formatter.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ module RailsStats
44
class JSONFormatter < StatsFormatter
55
def result
66
@result = []
7-
# Capture stdout
87
old_stdout = $stdout
98
$stdout = StringIO.new
109
Bundler::Stats::CLI.start(["-f", "json"])
1110
bundler_stats_cli_json_result = $stdout.string
1211
$stdout = old_stdout
1312

14-
# Parse and append the JSON result
1513
@result << JSON.parse(bundler_stats_cli_json_result) unless bundler_stats_cli_json_result.strip.empty?
1614

1715
@result += @statistics.map { |key, stats| stat_hash(key, stats) }
@@ -23,7 +21,7 @@ def result
2321
end
2422

2523
def to_s
26-
puts result.to_json
24+
puts JSON.generate(result, ascii_only: false)
2725
end
2826

2927
private

0 commit comments

Comments
 (0)