Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 34 lines (28 sloc) 0.686 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
def run_spec(file)
  unless File.exist?(file)
    puts "#{file} does not exist"
    return
  end

  puts "Running #{file}"
  system "bundle exec rspec #{file}"
  puts
end

watch("spec/.*/*_spec.rb") do |match|
  run_spec match[0]
end

def related_test_files(path)
  Dir.glob "spec/**/#{File.basename(path, File.extname(path))}_spec.rb"
end

watch('lib/.*') do |m|
  system('clear')
  if files = related_test_files(m[0]) and !files.empty?
    puts "bundle exec rspec #{files.join(" ")}"
    system "bundle exec rspec #{files.join(" ")}"
  end
end

Signal.trap('QUIT') do
  puts " --- Running all tests ---\n\n"
  system "bundle exec rake"
end

# Ctrl-C
Signal.trap('INT') { abort("\n") }
Something went wrong with that request. Please try again.