2012-09-08 23:27:41 -04:00
|
|
|
require 'guard/guard'
|
|
|
|
|
|
|
|
module ::Guard
|
|
|
|
class Bacon < Guard
|
|
|
|
def run_all
|
|
|
|
system "bundle exec bacon -Itest -q -a"
|
|
|
|
puts
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_spec(path)
|
|
|
|
if File.exists?(path)
|
2012-09-08 23:44:25 -04:00
|
|
|
success = system "bundle exec bacon -Itest -q #{path}"
|
|
|
|
|
|
|
|
if !success
|
|
|
|
@any_failed = true
|
|
|
|
end
|
|
|
|
|
2012-09-08 23:27:41 -04:00
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def file_changed(path)
|
|
|
|
run_spec(path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_on_changes(paths)
|
2012-09-08 23:44:25 -04:00
|
|
|
@any_failed = false
|
2012-09-08 23:27:41 -04:00
|
|
|
paths.delete(:all)
|
|
|
|
|
|
|
|
paths.each do |path|
|
|
|
|
file_changed(path)
|
|
|
|
end
|
|
|
|
|
2012-09-08 23:44:25 -04:00
|
|
|
if !@any_failed
|
|
|
|
run_all
|
|
|
|
end
|
2012-09-08 23:27:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
guard 'bacon' do
|
|
|
|
# Example of mapping a lib file to one or more test files
|
|
|
|
watch('lib/pry/indent.rb') { 'test/test_indent.rb' }
|
|
|
|
|
|
|
|
# If no such mapping exists, just run all of them
|
|
|
|
watch(%r{^lib/}) { :all }
|
|
|
|
|
|
|
|
# If we modified one test file, run it
|
|
|
|
watch(%r{^test.*/test_.+\.rb$})
|
|
|
|
end
|
|
|
|
|