Skip to content

Instantly share code, notes, and snippets.

@marten
Created April 5, 2013 06:08
Show Gist options
  • Save marten/5317010 to your computer and use it in GitHub Desktop.
Save marten/5317010 to your computer and use it in GitHub Desktop.
spork_options = {:rspec_env => { 'RAILS_ENV' => 'test' }, :wait => 60, :cucumber => false, :test_unit => false, :rspec_port => 8910 }
rspec_options = {:keep_failed => false, :all_after_pass => false, :all_on_start => false, :cli => "--drb --drb-port 8910 -f Fuubar --colour"}
teabag_options = {:keep_failed => false, :all_after_pass => false, :all_on_start => false}
def self.rspec_tests!(rspec_options)
guard :rspec, rspec_options do
# Rails example
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/integration/#{m[1]}_spec.rb"] }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs + view specs
watch(%r{^app/views/(.*)\.(erb|haml)$}) { |m| "spec/views/#{m[1]}_spec.rb" }
end
end
if File.exist?(override_file = 'Guardfile.local')
eval(File.read(override_file))
guard :shell do
watch(override_file) { ::Guard::Dsl.reevaluate_guardfile }
end
end
guard :spork, spork_options do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/routes.rb')
watch(%r{^Gemfile.*$})
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch(%r{^lib/(.+)\.rb$})
watch('spec/spec_helper.rb')
end
# type `tests` in the interactor to run all tests
group :tests do
rspec_tests! rspec_options
guard :teabag do
watch(%r{spec/javascripts/helpers/.*(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
watch(%r{^spec/javascripts/.*_factory\..*}) { 'spec/javascripts' }
watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)$}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" }
watch(%r{app/assets/javascripts/templates/(.+?)\.hamlc$}) { |m| "spec/javascripts/views/#{m[1]}_view_spec.coffee" }
end
end
guard :pow do
watch('.powrc')
watch('.powenv')
watch('.rvmrc')
watch('Gemfile')
watch('Gemfile.lock')
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.*\.rb$})
watch(%r{^config/initializers/.*\.rb$})
end
guard :shell do
watch(%r{^db/schema.rb$}) { `bundle exec rake db:test:load_schema` }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment