-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuardfile
38 lines (33 loc) · 1011 Bytes
/
Guardfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
guard :minitest, spring: true, all_on_start: false do
watch(%r{^lib\/(.+).rb$}) do |matches|
"test/lib/#{matches[1]}_test.rb"
end
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
watch('config/routes.rb') { integration_tests }
watch(%r{^app/models/(.*?)\.rb$}) do |matches|
"test/models/#{matches[1]}_test.rb"
end
watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches|
resource_tests(matches[1])
end
watch(%r{^app/views/([^/]*?)/.*\.html\.erb$}) do |matches|
["test/controllers/#{matches[1]}_controller_test.rb"] +
integration_tests(matches[1])
end
watch(%r{^app/helpers/(.*?)_helper\.rb$}) do |matches|
integration_tests(matches[1])
end
end
def integration_tests(resource = :all)
if resource == :all
Dir['test/integration/*']
else
Dir["test/integrations/#{resource}_*.rb"]
end
end
def controller_test(resource)
"test/controllers/#{resource}_controller_test.rb"
end
def resource_tests(resource)
integration_tests(resource) << controller_test(resource)
end