Skip to content

Instantly share code, notes, and snippets.

@andreareginato
Created October 2, 2012 16:49
Show Gist options
  • Save andreareginato/3821031 to your computer and use it in GitHub Desktop.
Save andreareginato/3821031 to your computer and use it in GitHub Desktop.
Rails Guardfile (handle Spork and RSpec automatic tests)
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch(%r{^config/locales/.+\.yml$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb')
end
guard 'rspec', cli: '--drb --format Fuubar --color', all_on_start: false, all_after_pass: false, :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)\.rb}) { |m| "spec/requests/#{m[1]}_spec.rb" }
watch(%r{^app/decorators/(.+)_decorator\.rb$}) { |m| "spec/requests/#{m[1]}_controller_spec.rb" }
watch('app/controllers/application_controller.rb') { "spec/requests" }
watch(%r{^app/views/(.+)/(.+)\.rabl$}) { |m| "spec/requests/#{m[1]}_controller_spec.rb" }
watch(%r{^spec/requests/support/views/(.+)_view\.rb$}) { |m| "spec/requests/#{m[1]}_controller_spec.rb" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment