.watchr in relation-0.3.5 vs .watchr in relation-0.3.7
- old
+ new
@@ -14,38 +14,32 @@
system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}"
end
def run_it(type, file)
case type
- when 'test'; run %Q{ruby -I test #{file}}
-# when 'spec'; run %Q{spring rspec -X #{file}}
+ when 'test'; run %(ruby -I test #{file})
+# when 'spec'; run %(rspec -X #{file})
else; puts "#{H} unknown type: #{type}, file: #{file}"
end
end
def run_all_tests
puts "\n#{HH} Running all tests #{HH}\n"
-# %w{test spec}.each { |dir| run "spring rake #{dir} RAILS_ENV=test" if File.exists?(dir) }
-# %w{test}.each { |dir| run "spring rake #{dir} RAILS_ENV=test" if File.exists?(dir) }
- %w{test}.each { |dir| run "rake #{dir} RAILS_ENV=test" if File.exists?(dir) }
+ %w[test spec].each { |dir| run "rake #{dir}" if File.exist?(dir) }
end
def run_matching_files(base)
base = base.split('_').first
- %w{test spec}.each { |type|
+ %w[test spec].each { |type|
files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
run_it type, files.join(' ') unless files.empty?
}
end
-%w{test spec}.each { |type|
+%w[test spec].each { |type|
watch("#{type}/#{type}_helper\.rb") { run_all_tests }
+ watch('lib/.*\.rb') { run_all_tests }
watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
-}
-%w{rb erb haml slim}.each { |type|
- watch("app/.*/.*\.#{type}") { |m|
- run_matching_files("#{m[0].split('/').at(2).split('.').first}")
- }
}
# Ctrl-\ or ctrl-4
Signal.trap('QUIT') { run_all_tests }
# Ctrl-C