|
| 1 | +# A sample Guardfile |
| 2 | +# More info at https://github.com/guard/guard#readme |
| 3 | + |
| 4 | +guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, |
| 5 | + :rspec_env => { 'RAILS_ENV' => 'test' } do |
| 6 | + watch('config/application.rb') |
| 7 | + watch('config/environment.rb') |
| 8 | + watch('config/environments/test.rb') |
| 9 | + watch(%r{^config/initializers/.+\.rb$}) |
| 10 | + watch('Gemfile') |
| 11 | + watch('Gemfile.lock') |
| 12 | + watch('spec/spec_helper.rb') { :rspec } |
| 13 | + watch('test/test_helper.rb') { :test_unit } |
| 14 | + watch(%r{features/support/}) { :cucumber } |
| 15 | +end |
| 16 | + |
| 17 | +guard 'rspec', after_all_pass: false, cli: '--drb' do |
| 18 | + watch(%r{^spec/.+_spec\.rb$}) |
| 19 | + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } |
| 20 | + watch('spec/spec_helper.rb') { "spec" } |
| 21 | + |
| 22 | + # Rails example |
| 23 | + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } |
| 24 | + watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } |
| 25 | + 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"] } |
| 26 | + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } |
| 27 | + watch('config/routes.rb') { "spec/routing" } |
| 28 | + watch('app/controllers/application_controller.rb') { "spec/controllers" } |
| 29 | + |
| 30 | + # Capybara features specs |
| 31 | + watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" } |
| 32 | + |
| 33 | + # Turnip features and steps |
| 34 | + watch(%r{^spec/acceptance/(.+)\.feature$}) |
| 35 | + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } |
| 36 | + |
| 37 | + # Custom Rails Tutorial specs |
| 38 | + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m| |
| 39 | + ["spec/routing/#{m[1]}_routing_spec.rb", |
| 40 | + "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", |
| 41 | + "spec/acceptance/#{m[1]}_spec.rb", |
| 42 | + (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : |
| 43 | + "spec/requests/#{m[1].singularize}_pages_spec.rb")] |
| 44 | + end |
| 45 | + watch(%r{^app/views/(.+)/}) do |m| |
| 46 | + (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : |
| 47 | + "spec/requests/#{m[1].singularize}_pages_spec.rb") |
| 48 | + end |
| 49 | + watch(%r{^app/controllers/sessions_controller\.rb$}) do |m| |
| 50 | + "spec/requests/authentication_pages_spec.rb" |
| 51 | + end |
| 52 | +end |
0 commit comments