Skip to content

Commit

Permalink
it's specs.watchr
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed May 18, 2010
1 parent c40aba3 commit 68ded07
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions specs.watchr
Expand Up @@ -5,12 +5,12 @@
# -------------------------------------------------- # --------------------------------------------------
# Convenience Methods # Convenience Methods
# -------------------------------------------------- # --------------------------------------------------
def all_test_files def all_spec_files
Dir['spec/**/*_spec.rb'] Dir['spec/**/*_spec.rb']
end end


def run_test_matching(thing_to_match) def run_spec_matching(thing_to_match)
matches = all_test_files.grep(/#{thing_to_match}/i) matches = all_spec_files.grep(/#{thing_to_match}/i)
if matches.empty? if matches.empty?
puts "Sorry, thanks for playing, but there were no matches for #{thing_to_match}" puts "Sorry, thanks for playing, but there were no matches for #{thing_to_match}"
else else
Expand All @@ -24,17 +24,17 @@ def run(files_to_run)
no_int_for_you no_int_for_you
end end


def run_all_tests def run_all_specs
run(all_test_files.join(' ')) run(all_spec_files.join(' '))
end end


# -------------------------------------------------- # --------------------------------------------------
# Watchr Rules # Watchr Rules
# -------------------------------------------------- # --------------------------------------------------
watch('^spec/(.*)_spec\.rb') { |m| run_test_matching(m[1]) } watch('^spec/(.*)_spec\.rb') { |m| run_spec_matching(m[1]) }
watch('^lib/(.*)\.rb') { |m| run_test_matching(m[1]) } watch('^lib/(.*)\.rb') { |m| run_spec_matching(m[1]) }
watch('^spec/spec_helper\.rb') { run_all_tests } watch('^spec/spec_helper\.rb') { run_all_specs }
watch('^spec/support/.*\.rb') { run_all_tests } watch('^spec/support/.*\.rb') { run_all_specs }


# -------------------------------------------------- # --------------------------------------------------
# Signal Handling # Signal Handling
Expand All @@ -52,7 +52,7 @@ Signal.trap 'INT' do
puts " Did you just send me an INT? Ugh. I'll quit for real if you do it again." puts " Did you just send me an INT? Ugh. I'll quit for real if you do it again."
@sent_an_int = true @sent_an_int = true
Kernel.sleep 1.5 Kernel.sleep 1.5
run_all_tests run_all_specs
end end
end end


Expand Down

0 comments on commit 68ded07

Please sign in to comment.