Sha256: 54ab1506b0dd2fec3cfb058672f5b355a6799d447781b4ad693a1c05c15af468

Contents?: true

Size: 1.1 KB

Versions: 61

Compression:

Stored size: 1.1 KB

Contents

def growl(title, msg, img)
  %x{growlnotify -m #{ msg.inspect} -t #{title.inspect} --image ~/.watchr/#{img}.png}
end

def form_growl_message(str)
  results = str.split("\n").last
  if results =~ /[1-9]\s(failure|error)s?/
    growl "Test Results", "#{results}", "fail"
  elsif results != ""
    growl "Test Results", "#{results}", "pass"
  end
end

def run(cmd)
  puts(cmd)
  output = ""
  IO.popen(cmd) do |com|
    com.each_char do |c|
      print c
      output << c
      $stdout.flush
    end
  end
  form_growl_message output
end

def run_test_file(file)
  run %Q(ruby -I"lib:test" -rubygems #{file})
end

def run_all_tests
  run "rake test"
end

def related_test_files(path)
  Dir['test/**/*.rb'].select { |file| file =~ /test_#{File.basename(path)}/ }
end

watch('test/test_helper\.rb') { system('clear'); run_all_tests }
watch('test/.*/test_.*\.rb') { |m| system('clear'); run_test_file(m[0]) }
watch('lib/.*') { |m| related_test_files(m[0]).each { |file| run_test_file(file) } }

# Ctrl-\
Signal.trap('QUIT') do
  puts " --- Running all tests ---\n\n"
  run_all_tests
end

# Ctrl-C
Signal.trap('INT') { abort("\n") }

Version data entries

61 entries across 61 versions & 9 rubygems

Version Path
mongo_mapper-unstable-2010.1.31 specs.watchr
mongo_mapper-unstable-2010.1.30 specs.watchr
mongo_mapper-unstable-2010.1.29 specs.watchr
mongo_mapper-unstable-2010.1.28 specs.watchr
mongo_mapper-unstable-2010.1.27 specs.watchr
mongo_mapper-unstable-2010.1.26 specs.watchr
mongo_mapper-unstable-2010.1.25 specs.watchr
mongo_mapper-unstable-2010.1.22 specs.watchr
mongo_mapper-unstable-2010.1.21 specs.watchr
mongo_mapper-unstable-2010.1.20 specs.watchr
mongo_mapper-unstable-2010.1.19 specs.watchr
jmonteiro-mongo_mapper-0.1.7 specs.watchr
mongo_mapper-unstable-2010.1.18 specs.watchr
jmonteiro-mongo_mapper-0.1.6 specs.watchr
jmonteiro-mongo_mapper-0.1.5 specs.watchr
mongo_mapper-unstable-2010.1.17 specs.watchr
jmonteiro-mongo_mapper-0.1.4 specs.watchr
jmonteiro-mongo_mapper-0.1.2 specs.watchr
jmonteiro-mongo_mapper-0.1.1 specs.watchr
jmonteiro-mongo_mapper-0.1.0 specs.watchr