diff --git a/lib/retest/options.rb b/lib/retest/options.rb index 7122fba..1192f84 100644 --- a/lib/retest/options.rb +++ b/lib/retest/options.rb @@ -70,6 +70,14 @@ class Options convert :list end + option :watcher do + desc "Tool used to watch file events" + permit %i[listen watchexec] + long "--watcher=" + short "-w" + convert :sym + end + flag :all do long "--all" desc "Run all the specs of a specificied ruby setup" @@ -160,6 +168,10 @@ def extensions params[:exts] end + def watcher + params[:watcher] || :listen + end + def extensions_regex Regexp.new("\\.(?:#{extensions.join("|")})$") end diff --git a/test/retest/options/help.txt b/test/retest/options/help.txt index 4b5f9bf..0a43a4d 100644 --- a/test/retest/options/help.txt +++ b/test/retest/options/help.txt @@ -24,6 +24,8 @@ Options: --rspec Shortcut for a standard RSpec setup --ruby Shortcut for a Ruby project -v, --version Print retest version + -w, --watcher= Tool used to watch file events (permitted: listen, + watchexec) Examples: Runs a matching rails test after a file change diff --git a/test/retest/options_test.rb b/test/retest/options_test.rb index 65aa604..24e1479 100644 --- a/test/retest/options_test.rb +++ b/test/retest/options_test.rb @@ -85,5 +85,25 @@ def test_all_version_copy assert_equal %w[--notify --rake --all], copy.args refute_equal copy.object_id, @subject.object_id end + + def test_listener + @subject.args = %w[--watcher=watchexec] + assert_equal :watchexec, @subject.watcher + + @subject.args = %w[-w watchexec] + assert_equal :watchexec, @subject.watcher + + @subject.args = %w[--watcher=listen] + assert_equal :listen, @subject.watcher + + @subject.args = %w[-w listen] + assert_equal :listen, @subject.watcher + + @subject.args = %w[-w hello] + assert_equal :listen, @subject.watcher + + @subject.args = %w[] # default when no listeners are install by default + assert_equal :listen, @subject.watcher + end end end \ No newline at end of file