From e01d2a906614592bc18af2df510fd09cf82232a2 Mon Sep 17 00:00:00 2001 From: Alexandre Barret Date: Mon, 2 Dec 2024 09:47:58 +1300 Subject: [PATCH] Remove .puts (for now) --- exe/retest | 26 +++++++++---------- features/hanami-app/retest/retest_test.rb | 2 ++ features/rails-app/retest/retest_test.rb | 2 ++ features/rspec-rails/retest/retest_test.rb | 2 ++ .../retest/retest_test/flags_test.rb | 1 + .../ruby-app/retest/retest_test/flags_test.rb | 1 + .../ruby-bare/retest/scenarios/auto_flag.rb | 1 + .../retest/retest_test/file_changes_test.rb | 2 +- 8 files changed, 23 insertions(+), 14 deletions(-) diff --git a/exe/retest b/exe/retest index e956d1b..651270f 100755 --- a/exe/retest +++ b/exe/retest @@ -5,7 +5,7 @@ require 'retest' $stdout.sync = true listen_rd, listen_wr = IO.pipe Signal.trap(:INT) do - $stdout.puts "Goodbye" + puts "Goodbye" listen_rd.close listen_wr.close exit @@ -14,12 +14,12 @@ end options = Retest::Options.new(ARGV) if options.help? - $stdout.puts options.help + puts options.help return end if options.version? - $stdout.puts Retest::VERSION + puts Retest::VERSION return end @@ -28,13 +28,7 @@ repository = Retest::Repository.new(files: Retest::VersionControl.files, prompt: command = Retest::Command.for_options(options) runner = Retest::Runner.new(command) sounds = Retest::Sounds.for(options) -watcher = Retest::Watcher.for(options.watcher).tap do |tool| - if tool == Retest::Watcher::Watchexec - puts "Watcher: [WATCHEXEC]" - else Retest::Watcher::Default - puts "Watcher: [LISTEN]" - end -end +watcher = Retest::Watcher.for(options.watcher) sounds.play(:start) runner.add_observer(sounds) @@ -50,6 +44,12 @@ if options.params[:diff] return end +if watcher == Retest::Watcher::Watchexec + puts "Watcher: [WATCHEXEC]" +else Retest::Watcher::Default + puts "Watcher: [LISTEN]" +end + launching_message = "Launching Retest..." if options.force_polling? launching_message = "Launching Retest with polling method..." @@ -57,7 +57,7 @@ end # Main action -$stdout.puts launching_message +puts launching_message Retest.listen(options, listener: watcher) do |modified, added, removed| begin repository.sync(added: added, removed: removed) @@ -65,10 +65,10 @@ Retest.listen(options, listener: watcher) do |modified, added, removed| listen_wr.puts "file changed: #{(modified + added).first}" rescue => e - $stdout.puts "Something went wrong: #{e.message}" + puts "Something went wrong: #{e.message}" end end -$stdout.puts "Ready to refactor! You can make file changes now" +puts "Ready to refactor! You can make file changes now" def run_command(input:, program:) program.clear_terminal diff --git a/features/hanami-app/retest/retest_test.rb b/features/hanami-app/retest/retest_test.rb index 6fbf350..8b0709d 100644 --- a/features/hanami-app/retest/retest_test.rb +++ b/features/hanami-app/retest/retest_test.rb @@ -71,6 +71,7 @@ def test_with_no_command assert_match <<~OUTPUT, @output.read Setup identified: [RAKE]. Using command: 'bundle exec rake test TEST=' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT @@ -81,6 +82,7 @@ def test_with_no_command_all assert_match <<~OUTPUT, @output.read Setup identified: [RAKE]. Using command: 'bundle exec rake test' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT diff --git a/features/rails-app/retest/retest_test.rb b/features/rails-app/retest/retest_test.rb index a8c5c48..3fe1af5 100644 --- a/features/rails-app/retest/retest_test.rb +++ b/features/rails-app/retest/retest_test.rb @@ -71,6 +71,7 @@ def test_with_no_command assert_match <<~OUTPUT, @output.read Setup identified: [RAILS]. Using command: 'bin/rails test ' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT @@ -81,6 +82,7 @@ def test_with_no_command_all assert_match <<~OUTPUT, @output.read Setup identified: [RAILS]. Using command: 'bin/rails test' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT diff --git a/features/rspec-rails/retest/retest_test.rb b/features/rspec-rails/retest/retest_test.rb index a8a796c..8035ad0 100644 --- a/features/rspec-rails/retest/retest_test.rb +++ b/features/rspec-rails/retest/retest_test.rb @@ -71,6 +71,7 @@ def test_with_no_command assert_match <<~OUTPUT, @output.read Setup identified: [RSPEC]. Using command: 'bundle exec rspec ' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT @@ -81,6 +82,7 @@ def test_with_no_command_all assert_match <<~OUTPUT, @output.read Setup identified: [RSPEC]. Using command: 'bundle exec rspec' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT diff --git a/features/rspec-ruby/retest/retest_test/flags_test.rb b/features/rspec-ruby/retest/retest_test/flags_test.rb index 66da617..1dab0d8 100644 --- a/features/rspec-ruby/retest/retest_test/flags_test.rb +++ b/features/rspec-ruby/retest/retest_test/flags_test.rb @@ -11,6 +11,7 @@ def test_with_no_command assert_match <<~OUTPUT, @output.read Setup identified: [RSPEC]. Using command: 'bundle exec rspec ' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT diff --git a/features/ruby-app/retest/retest_test/flags_test.rb b/features/ruby-app/retest/retest_test/flags_test.rb index 25dd51c..73e6b73 100644 --- a/features/ruby-app/retest/retest_test/flags_test.rb +++ b/features/ruby-app/retest/retest_test/flags_test.rb @@ -11,6 +11,7 @@ def test_with_no_command assert_match <<~OUTPUT, @output.read Setup identified: [RUBY]. Using command: 'bundle exec ruby ' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT diff --git a/features/ruby-bare/retest/scenarios/auto_flag.rb b/features/ruby-bare/retest/scenarios/auto_flag.rb index 3186718..95185c2 100644 --- a/features/ruby-bare/retest/scenarios/auto_flag.rb +++ b/features/ruby-bare/retest/scenarios/auto_flag.rb @@ -8,6 +8,7 @@ def test_start_retest assert_match <<~OUTPUT, @output.read Setup identified: [RUBY]. Using command: 'ruby ' + Watcher: [LISTEN] Launching Retest... Ready to refactor! You can make file changes now OUTPUT diff --git a/features/watchexec-ruby-app/retest/retest_test/file_changes_test.rb b/features/watchexec-ruby-app/retest/retest_test/file_changes_test.rb index 65c20d7..ff43d57 100644 --- a/features/watchexec-ruby-app/retest/retest_test/file_changes_test.rb +++ b/features/watchexec-ruby-app/retest/retest_test/file_changes_test.rb @@ -8,8 +8,8 @@ def test_start_retest launch_retest(COMMAND) assert_match <<~EXPECTED, @output.read - Watcher: [WATCHEXEC] Setup identified: [RUBY]. Using command: 'bundle exec ruby ' + Watcher: [WATCHEXEC] Launching Retest... Ready to refactor! You can make file changes now EXPECTED