Sha256: 32d6b3b82321799265d51e91aa10fd532b2c0a92941dbdfb4ff36fc28a9aa835

Contents?: true

Size: 777 Bytes

Versions: 10

Compression:

Stored size: 777 Bytes

Contents

def run(cmd)
  puts(cmd)
  output = ""
  IO.popen(cmd) do |com|
    com.each_char do |c|
      print c
      output << c
      $stdout.flush
    end
  end
  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

10 entries across 10 versions & 2 rubygems

Version Path
joint-0.6.2 specs.watchr
jamieorc-joint-0.6.2 specs.watchr
joint-0.6.1 specs.watchr
jamieorc-joint-0.6.1 specs.watchr
jamieorc-joint-0.5.6 specs.watchr
joint-0.6.0 specs.watchr
joint-0.5.5 specs.watchr
joint-0.5.4 specs.watchr
joint-0.5.3 specs.watchr
joint-0.5.2 specs.watchr