Skip to content

Instantly share code, notes, and snippets.

@hughevans
Created August 1, 2016 01:45
Show Gist options
  • Save hughevans/52bd6a11f959427b4ccc3803b9d15a0f to your computer and use it in GitHub Desktop.
Save hughevans/52bd6a11f959427b4ccc3803b9d15a0f to your computer and use it in GitHub Desktop.
group :red_green_refactor, halt_on_fail: true do
guard :rspec, cmd: './bin/rspec' 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{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*(\.slim)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end
guard :rubocop, all_on_start: false do
watch(%r{.+\.rb$})
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
end
guard :bundler do
require 'guard/bundler'
require 'guard/bundler/verify'
helper = Guard::Bundler::Verify.new
files = ['Gemfile']
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
# Assume files are symlinked from somewhere
files.each { |file| watch(helper.real_path(file)) }
end
guard 'puma', port: 3000 do
watch('.env')
watch('Gemfile.lock')
watch(%r{^config|lib/.*})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment