forked from pry/pry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guardfile
62 lines (55 loc) · 1.29 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require 'guard/guard'
module ::Guard
class Bacon < Guard
def run_all
system "rake spec"
puts
true
end
def run_on_changes(paths)
paths.delete('some_lib')
puts "Running: #{paths.join ' '}"
if paths.size.zero?
warn 'Running all tests'
system 'rake recspec'
else
paths.each do |path|
warn "Running #{path}"
system "rake spec run=#{path}" or return
warn "\e[32;1mNice!!\e[0m Now running all specs, just to be sure."
run_all
end
end
end
end
end
guard 'bacon' do
def deduce_spec_from(token)
%W(
spec/#{token}_spec.rb
spec/pry_#{token}_spec.rb
spec/commands/#{token}_spec.rb
).each do |e|
return e if File.exists? e
end
nil
end
Dir['lib/pry/**/*.rb'].each do |rb|
rb[%r(lib/pry/(.+)\.rb$)]
spec_rb = deduce_spec_from($1)
if spec_rb
# run as 'bundle exec guard -d' to see these.
::Guard::UI.debug "'#{rb}' maps to '#{spec_rb}'"
else
::Guard::UI.debug "No map, so run all for: '#{rb}'"
end
next unless spec_rb
watch(rb) do |m| spec_rb end
end
watch(%r{^lib/.+\.rb$}) do |m|
return if deduce_spec_from(m[0])
'some_lib'
end
watch(%r{^spec/.+\.rb$}) do |m| m end
end
# vim:ft=ruby