From 3863956ddf0ed23a7d23e9ecd89640e9328fd97b Mon Sep 17 00:00:00 2001 From: "Ruy R." <108208+ruyrocha@users.noreply.github.com> Date: Sat, 14 Jun 2025 12:30:18 -0300 Subject: [PATCH 1/3] [#30] Explicitly set format as text for `Bundler::Stats::CLI` on `ConsoleFormatter`. --- CHANGELOG.md | 1 + lib/rails_stats/console_formatter.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03655ae..e7bb575 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # main ([unreleased](https://github.com/fastruby/rails_stats/compare/v1.0.2...main)) * [CHORE: Improve the GH Test Workflow](https://github.com/fastruby/rails_stats/pull/35) +* [BUGFIX: Explicitly set format as text for `Bundler::Stats::CLI` on `ConsoleFormatter`](https://github.com/fastruby/rails_stats/pull/40) * [BUGFIX: Fix JSON output missing Code and Tests total count](https://github.com/fastruby/rails_stats/pull/40) * Update README examples * [FEATURE: Output number of tables created from schema.rb or structure.sql, add polymorphic models count](https://github.com/fastruby/rails_stats/pull/37) diff --git a/lib/rails_stats/console_formatter.rb b/lib/rails_stats/console_formatter.rb index e12fae1..83b56d0 100644 --- a/lib/rails_stats/console_formatter.rb +++ b/lib/rails_stats/console_formatter.rb @@ -3,7 +3,7 @@ module RailsStats class ConsoleFormatter < StatsFormatter def to_s - Bundler::Stats::CLI.start + Bundler::Stats::CLI.start(['--format', 'text']) print_header sorted_keys = @statistics.keys.sort @@ -70,4 +70,4 @@ def print_schema_stats end end end -end \ No newline at end of file +end From 2ea3bb195e58ed5c18c9498c975e31452d8223df Mon Sep 17 00:00:00 2001 From: Ruy Rocha <108208+ruyrocha@users.noreply.github.com> Date: Wed, 1 Apr 2026 02:16:47 -0300 Subject: [PATCH 2/3] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Juan Vásquez --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7bb575..5b3a432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # main ([unreleased](https://github.com/fastruby/rails_stats/compare/v1.0.2...main)) * [CHORE: Improve the GH Test Workflow](https://github.com/fastruby/rails_stats/pull/35) -* [BUGFIX: Explicitly set format as text for `Bundler::Stats::CLI` on `ConsoleFormatter`](https://github.com/fastruby/rails_stats/pull/40) +* [BUGFIX: Explicitly set format as text for `Bundler::Stats::CLI` on `ConsoleFormatter`](https://github.com/fastruby/rails_stats/pull/43) * [BUGFIX: Fix JSON output missing Code and Tests total count](https://github.com/fastruby/rails_stats/pull/40) * Update README examples * [FEATURE: Output number of tables created from schema.rb or structure.sql, add polymorphic models count](https://github.com/fastruby/rails_stats/pull/37) From f362382b8f3bbe9a6383e28ad8b4fb4b7a1e8210 Mon Sep 17 00:00:00 2001 From: Ruy Rocha <108208+ruyrocha@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:12:37 -0300 Subject: [PATCH 3/3] add: unit test console formatter `.to_s`. --- .../lib/rails_stats/console_formatter_test.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/lib/rails_stats/console_formatter_test.rb diff --git a/test/lib/rails_stats/console_formatter_test.rb b/test/lib/rails_stats/console_formatter_test.rb new file mode 100644 index 0000000..60f318a --- /dev/null +++ b/test/lib/rails_stats/console_formatter_test.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'test_helper' + +describe RailsStats::ConsoleFormatter do + describe '#to_s' do + it 'invokes Bundler::Stats::CLI with text format' do + root_directory = File.absolute_path('./test/dummy') + calculator = RailsStats::StatsCalculator.new(root_directory) + formatter = RailsStats::ConsoleFormatter.new(calculator) + + received_args = nil + original = Bundler::Stats::CLI.method(:start) + Bundler::Stats::CLI.define_singleton_method(:start) { |args = []| received_args = args } + + begin + capture_io { formatter.to_s } + ensure + Bundler::Stats::CLI.singleton_class.remove_method(:start) + Bundler::Stats::CLI.define_singleton_method(:start, original) + end + + assert_equal ['--format', 'text'], received_args + end + end +end