Guard with minitest
Set up guard with minitest
Used 116 times
T
TobiasBales
Usage
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/VqqsYW"
Template Source
Review the code before running this template on your machine.
if File.exists? 'Guardfile'
puts 'Guardfile already exists, skipping guard setup'
return
end
gem_group :development, :test do
gem 'guard'
gem 'guard-minitest'
gem 'terminal-notifier-guard'
end
Bundler.with_unbundled_env { run 'bundle install' }
create_file 'Guardfile' do <<~EOF
notification :terminal_notifier if /Darwin/.match?(\`uname\`)
guard :minitest, spring: "bin/rails test" do
watch(%r{^app/(.+)\.rb$}) { |m| "test/\#{m[1]}_test.rb" }
watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/\#{m[1]}_test.rb" }
watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/\#{m[1]}_mailer_test.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/\#{m[1]}_test.rb" }
watch(%r{^test/.+_test\.rb$})
watch(%r{^test/test_helper\.rb$}) { 'test' }
end
EOF
end
if File.exist?('Procfile.dev')
inject_into_file 'Procfile.dev' do <<~EOF
guard: guard
EOF
end
end
`bin/spring stop`