Sha256: 4ec119a2e9a8daf39d6e33c5c71b6855704a20f6b0519108027b8d49de76e097

Contents?: true

Size: 1.63 KB

Versions: 8

Compression:

Stored size: 1.63 KB

Contents

# Run me with:
#
#   $ watchr specs.watchr

# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def all_test_files
  Dir['test/**/test_*.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)
  puts("Running: #{files_to_run}")
  system("ruby -Ilib -Itest #{files_to_run}")
  no_int_for_you
end

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

# --------------------------------------------------
# Watchr Rules
# --------------------------------------------------
watch('^test/test_(.*)\.rb'  )          { |m| run_test_matching(m[1]) }
#watch('^app/(.*)\.rb'               )   { |m| run_test_matching(m[1]) }
#watch('^app/views/(.*)/(.*)')           { |m| run_test_matching(m[1]) }
watch('^lib/(.*)\.rb'               )   { |m| run_test_matching(m[1]) }
watch('^lib/xml/util/xmlcanonicalizer.rb') { run('test/test_xmlcanonicalizer.rb')}

# --------------------------------------------------
# Signal Handling
# --------------------------------------------------

def no_int_for_you
  @sent_an_int = nil
end

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

puts "Save a file to get watchr's attention."

# vim:ft=ruby

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
canonix-0.1.7 tests.watchr
xmlcanonicalizer-0.1.2 tests.watchr
canonix-0.1.5 tests.watchr
xmlcanonicalizer-0.1.1 tests.watchr
canonix-0.1.4 tests.watchr
canonix-0.1.3 tests.watchr
canonix-0.1.2 tests.watchr
canonix-0.1.1 tests.watchr