require 'autotest/bundler'
require 'autotest/restart'

# Let child processes know that they're running under autotest,
# so they can disable test-coverage reporting, etc.
ENV["AUTOTEST"] = "1"

Autotest.add_hook :initialize do |autotest|
  autotest.order = :random

  %w(.git coverage log vendor).each do |directory|
    autotest.add_exception(directory)
  end

  # Our tests are fast enough that it's reasonable to just run 'em all
  # whenever something changes
  autotest.clear_mappings
  autotest.add_mapping /^Gemfile|^Rakefile|\.gemspec$|\.rb$/ do
    autotest.files_matching %r|^test/test_\w+\.rb$|
  end
end

Autotest.add_hook :run_command do |at|
  system "bundle exec rake test:preflight"
end
