# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'spork', :test_unit_env => { 'RAILS_ENV' => 'test' } do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch('config/environments/test.rb')
  watch(%r{^config/initializers/.+\.rb$})
  watch('Gemfile')
  watch('Gemfile.lock')
  watch('test/test_helper.rb') { :test_unit }
end

guard 'minitest', :drb => true do
  # with Minitest::Unit
  #watch(%r|^test/(.*)\/?test_(.*)\.rb|)
  #watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
  watch(%r|^test/test_helper\.rb|)    { "test" }

  # Rails 3.2
  watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
  watch(%r|^app/helpers/(.*)\.rb|)     { |m| "test/helpers/#{m[1]}_test.rb" }
  watch(%r|^app/models/(.*)\.rb|)      { |m| "test/unit/#{m[1]}_test.rb" }

  watch(%r!^test/.+/.+_test\.rb!)
  watch(%r!^test/(.+)_test_helper.rb!) { |m| "test/#{m[1]}" }

  # For factory_girl
  require 'active_support/inflector'
  watch(%r!^test/factories/(.+)\.rb$!) do |m|
    %W[
      test/unit/#{m[1].singularize}_test.rb
      test/functional/#{m[1]}_controller_test.rb
    ]
  end
end

# vim: set ft=ruby:
