Created
January 8, 2012 20:03
-
-
Save aspiers/1579497 to your computer and use it in GitHub Desktop.
Guardfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# More info at https://github.com/guard/guard#readme | |
#USE_SPORK = false | |
USE_SPORK = true | |
guard_opts = { | |
all_on_start: true, | |
all_after_pass: true, | |
} | |
def startup_guards | |
watch('Gemfile') | |
watch('Gemfile.lock') | |
watch('config/application.rb') | |
watch('config/environment.rb') | |
watch(%r{^config/environments/.+\.rb$}) | |
watch(%r{^config/initializers/.+\.rb$}) | |
end | |
def test_time_guards | |
watch(%r{^test/test_helper\.rb}) { "test" } | |
watch(%r{^test/.+_test\.rb$}) | |
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" } | |
watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" } | |
watch(%r{^app/views/.+\.rb$}) { "test/integration" } | |
watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] } | |
# with Minitest::Spec | |
# watch('spec/spec_helper.rb') { :rspec } | |
# watch('test/test_helper.rb') { :test_unit } | |
# watch(%r{features/support/}) { :cucumber } | |
# watch(%r|^spec/(.*)_spec\.rb|) | |
# watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" } | |
end | |
spork_envs = %w( | |
test | |
minitest | |
test_unit | |
) | |
spork_opts = { | |
spec: false, | |
rspec: false, | |
cucumber: false, | |
} | |
spork_opts.merge Hash[ *spork_envs.map { |e| ["#{e}_env".to_sym, { RAILS_ENV: 'test' }] }.flatten ] | |
if USE_SPORK | |
guard 'spork', spork_opts do | |
startup_guards | |
end | |
end | |
cli_opts = if USE_SPORK then { cli: '--drb' } else {} end | |
#guard 'rspec', guard_opts.merge cli_opts do | |
#guard 'test', guard_opts do | |
guard 'minitest', guard_opts.merge(drb: USE_SPORK, verbose: true) do | |
startup_guards | |
test_time_guards | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment