diff --git a/exe/retest b/exe/retest index da14480f..a30cc2d9 100755 --- a/exe/retest +++ b/exe/retest @@ -13,13 +13,15 @@ if options.help? return end -repository = Retest::Repository.new(files: Retest::VersionControl.files) +prompt = Retest::Prompt.new +repository = Retest::Repository.new(files: Retest::VersionControl.files, prompt: prompt) command = Retest::Command.for_options(options) runner = Retest::Runners.runner_for(command.to_s) sounds = Retest::Sounds.for(options) sounds.play(:start) runner.add_observer(sounds) +prompt.add_observer(sounds) program = Retest::Program.new( repository: repository, diff --git a/lib/retest/prompt.rb b/lib/retest/prompt.rb index 54dd92dc..2409f4a3 100644 --- a/lib/retest/prompt.rb +++ b/lib/retest/prompt.rb @@ -1,5 +1,7 @@ module Retest class Prompt + include Observable + def self.ask_which_test_to_use(path, files) new.ask_which_test_to_use(path, files) end @@ -15,6 +17,9 @@ def initialize(input: nil, output: nil) end def ask_which_test_to_use(path, files) + changed + notify_observers(:question) + output.puts(<<~QUESTION) We found few tests matching: #{path} diff --git a/lib/retest/sounds.rb b/lib/retest/sounds.rb index 9a59e22a..ab76b825 100644 --- a/lib/retest/sounds.rb +++ b/lib/retest/sounds.rb @@ -26,6 +26,8 @@ def play(sound) ['afplay', '/System/Library/Sounds/Funk.aiff'] when :start ['afplay', '/System/Library/Sounds/Blow.aiff'] + when :question + ['afplay', '/System/Library/Sounds/Glass.aiff'] else raise ArgumentError.new("No sounds were found for type: #{sound}.") end @@ -40,15 +42,18 @@ def play(sound) # List of Mac Audio Files: # afplay /System/Library/Sounds/Basso.aiff # afplay /System/Library/Sounds/Bottle.aiff -# afplay /System/Library/Sounds/Funk.aiff # afplay /System/Library/Sounds/Hero.aiff # afplay /System/Library/Sounds/Ping.aiff # afplay /System/Library/Sounds/Purr.aiff # afplay /System/Library/Sounds/Submarine.aiff -# afplay /System/Library/Sounds/Blow.aiff # afplay /System/Library/Sounds/Frog.aiff -# afplay /System/Library/Sounds/Glass.aiff # afplay /System/Library/Sounds/Morse.aiff # afplay /System/Library/Sounds/Pop.aiff -# afplay /System/Library/Sounds/Sosumi.aiff # afplay /System/Library/Sounds/Tink.aiff + +# USED + +# fail: afplay /System/Library/Sounds/Sosumi.aiff +# pass: afplay /System/Library/Sounds/Funk.aiff +# start: afplay /System/Library/Sounds/Blow.aiff +# question: afplay /System/Library/Sounds/Glass.aiff \ No newline at end of file diff --git a/test/retest/sounds/mac_os_test.rb b/test/retest/sounds/mac_os_test.rb index fdda660e..a0b4179c 100644 --- a/test/retest/sounds/mac_os_test.rb +++ b/test/retest/sounds/mac_os_test.rb @@ -33,6 +33,24 @@ def test_play_tests_fail kernel.verify end + + def test_play_question + kernel = MiniTest::Mock.new + kernel.expect(:system, true, ['afplay', '/System/Library/Sounds/Glass.aiff']) + + MacOS.new(kernel: kernel, thread: FakeThread).play(:question) + + kernel.verify + end + + def test_play_start + kernel = MiniTest::Mock.new + kernel.expect(:system, true, ['afplay', '/System/Library/Sounds/Blow.aiff']) + + MacOS.new(kernel: kernel, thread: FakeThread).play(:start) + + kernel.verify + end end end end