Skip to content

Instantly share code, notes, and snippets.

@christopherhein
Created October 10, 2011 08:54
Show Gist options
  • Save christopherhein/1274903 to your computer and use it in GitHub Desktop.
Save christopherhein/1274903 to your computer and use it in GitHub Desktop.
# Setup Spork
guard 'spork', bundler: true, cucumber_env: { 'RAILS_ENV' => 'test' }, rspec_env: { 'RAILS_ENV' => 'test' }, test_unit_env: { 'RAILS_ENV' => 'test' }, wait: 60 do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch(%r{^spec/support/.+\.rb$})
watch('spec/spec_helper.rb')
watch('test/test_helper.rb')
watch(%r{^features/support/.+\.rb$})
end
# Reload with new gems
guard 'bundler' do
watch('Gemfile')
end
# Migrate the database
guard 'migrate', run_on_start: true do
watch(%r{^db/migrate/(\d+).+\.rb})
end
# Run Coffeescript Validation
guard 'coffeescript', :input => 'app/assets/javascripts', :noop => true
# Use Headless Jasmine
spec_location = "spec/javascripts/%s_spec"
guard 'jasmine-headless-webkit' do
watch(%r{^app/views/.*\.jst$})
watch(%r{^public/javascripts/(.*)\.js$}) { |m| newest_js_file(spec_location % m[1]) }
watch(%r{^app/assets/javascripts/(.*)\.(js|coffee)$}) { |m| newest_js_file(spec_location % m[1]) }
watch(%r{^spec/javascripts/(.*)_spec\..*}) { |m| newest_js_file(spec_location % m[1]) }
end
# Run Test::Unit
guard 'test', bundler: true, drb: true, all_after_pass: false, all_on_start: false do
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
watch(%r{^test/.+_test\.rb$})
watch('test/test_helper.rb') { "test" }
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
end
# Run Rspec
guard 'rspec', bundler: true, version: 2, cli: "--drb", all_after_pass: false, all_on_start: false do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# 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/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end
# Run Cuke Features
guard 'cucumber', bundler: true, cli: "--drb", all_after_pass: false, all_on_start: false do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end
# Reload The Browser when changes are made.
guard 'livereload' do
watch(%r{app/.+\.(erb|haml)})
watch(%r{app/helpers/.+\.rb})
watch(%r{(public/|app/assets).+\.(css|js|html)})
watch(%r{(app/assets/.+\.css)\.s[ac]ss}) { |m| m[1] }
watch(%r{(app/assets/.+\.js)\.coffee}) { |m| m[1] }
watch(%r{config/locales/.+\.yml})
end
# Restart pow if things change
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
# Use Sprite Factory when files Change
# guard 'sprite-factory', :task_name => 'assets:resprite' do
# watch(%r{^app/assets/images/admin/icons/*.*})
# watch(%r{^lib/tasks/assets.rake})
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment