-
Notifications
You must be signed in to change notification settings - Fork 1
/
Guardfile
23 lines (22 loc) · 1.33 KB
/
Guardfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'active_support/inflector'
guard :rspec, cmd: 'bin/rspec -f doc' do
# spec/*_helper.rb -> all specs
watch(%r{spec/.*_helper.rb}) { 'spec' }
# spec/support/*.rb -> all specs
watch(%r{spec/support/.*.rb}) { 'spec' }
# app/**/(application|base)_*.rb--> all relevant spec groups
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
watch('app/resources/base_resource.rb') { 'spec/controllers' }
watch('app/policies/application_policy.rb') { 'spec/policies' }
# spec/**/* --> itself
watch(%r{^spec/.+_spec\.rb$})
# app/**/* -> corresponding spec
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
# lib/**/* -> corresponding spec
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
# app/resources/* and app/policies/* --> controller spec
watch(%r{^app/resources/(.+)_resource\.rb$}) { |m| "spec/controllers/#{m[1].pluralize}_controller_spec.rb" }
watch(%r{^app/policies/(.+)_policy\.rb$}) { |m| "spec/controllers/#{m[1].pluralize}_controller_spec.rb" }
# spec/factories/*.rb --> factories_spec & related model spec
watch(%r{^spec/factories/(.+).rb}) { |m| ["spec/factories_spec.rb", "spec/models/#{m[1].singularize}_spec.rb"] }
end