Sha256: 029da66a829511bd9578436bd4214f9a3c1054533869f0f10bb4e69a415ea119
Contents?: true
Size: 1.8 KB
Versions: 2
Compression:
Stored size: 1.8 KB
Contents
#!/usr/bin/env ruby # -------------------------------------------------- # Convenience Methods # -------------------------------------------------- if __FILE__ == $0 exec("watchr #{__FILE__}") end def test_folder @test_folder ||= %w[spec specs examples test].detect { |p| File.directory?(p) } end def test_suffix case test_folder when "spec", "specs" then "spec" when "examples" then "example" when "test" then "test" end end def all_test_files Dir["#{test_folder}/**/*_#{test_suffix}.rb"] end def run_test_matching(thing_to_match) matches = all_test_files.grep /#{thing_to_match}/i if matches.empty? puts "Sorry, thanks for playing, but there were no matches for #{thing_to_match}" else run matches.join(' ') end end def run(files_to_run) cmd = "ruby -I#{test_folder} #{files_to_run}" puts cmd system("ruby -I#{test_folder} #{files_to_run}") end def run_all_tests run(all_test_files.join(' ')) end # -------------------------------------------------- # Watchr Rules # -------------------------------------------------- watch("^lib/(.*)\.rb") { |m| run_test_matching(m[1]) } watch("^#{test_folder}/(.*)_#{test_suffix}\.rb") { |m| run_test_matching(m[1]) } watch("^#{test_folder}/(.*)\.rb") { |m| run_test_matching(m[1]) } watch("^#{test_folder}/#{test_suffix}_helper\.rb") { run_all_tests } watch('^features/(.*)') { system "cucumber --tags @fit features/other/" } # -------------------------------------------------- # Signal Handling # -------------------------------------------------- Signal.trap 'INT' do if @sent_an_int then puts " A second INT? Ok, I get the message. Shutting down now." exit else puts " Did you just send me an INT? Ugh. I'll quit for real if you do it again." @sent_an_int = true Kernel.sleep 1.5 run_all_tests end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
watch-me-now-1.1.1 | bin/watch-me-now |
watch-me-now-1.0.0 | bin/watch-me-now |