1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/Guardfile
☈king 0b5b06d906 Deduce the test name from lib names for Guard
There will still be a need for manual coaching, but this is a quick start.
2012-09-17 01:12:40 -06:00

64 lines
1.2 KiB
Ruby

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)
@success &&= system "bundle exec bacon -Itest -q #{path}"
puts
end
end
def file_changed(path)
run_spec(path)
end
def run_on_changes(paths)
@success = true
paths.delete(:all)
paths.each do |path|
file_changed(path)
end
run_all if @success
end
end
end
guard 'bacon' do
def deduce_test_from(token)
"test/test_#{token}.rb"
end
Dir['lib/pry/*.rb'].each do |rb|
rb[%r(lib/pry/(.+)\.rb$)]
test_rb = deduce_test_from $1
if File.exists?(test_rb)
watch(rb) { test_rb }
else
exempt = %w(
commands
version
).map {|token| deduce_test_from token}
puts 'Missing ' + test_rb if
ENV['WANT_TEST_COMPLAINTS'] and not exempt.include?(test_rb)
end
end
watch(%r{^lib/pry/commands/([^.]+)\.rb}) { |m| "test/test_commands/test_#{m[1]}.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
# vim:ft=ruby