Skip to content

Instantly share code, notes, and snippets.

@saboyutaka
Created August 24, 2013 04:31
Show Gist options
  • Save saboyutaka/6326067 to your computer and use it in GitHub Desktop.
Save saboyutaka/6326067 to your computer and use it in GitHub Desktop.
Guardfile for Rails.
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
require 'active_support/inflector'
guard :rubocop, cli: ['--format', 'clang', '--silent'] do
watch(%r{.+\.rb$})
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
guard :rspec, cli: '--color --fail-fast', spring: true do
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^spec/factories/(.*)\.rb$}) { |m| "spec/models/#{m[1].singularize}_spec.rb" }
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
["spec/routing/#{m[1]}_routing_spec.rb",
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment