.watchr in relation-0.3.7 vs .watchr in relation-0.3.8

- old
+ new

@@ -1,5 +1,6 @@ +TESTING = %w[test] HH = '#' * 22 unless defined?(HH) H = '#' * 5 unless defined?(H) def usage puts <<-EOS @@ -14,32 +15,42 @@ system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}" end def run_it(type, file) case type - when 'test'; run %(ruby -I test #{file}) + when 'test'; run %(bundle exec 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 "rake #{dir}" if File.exist?(dir) } + TESTING.each { |dir| run "bundle exec rake #{dir}" if File.exist?(dir) } end def run_matching_files(base) base = base.split('_').first - %w[test spec].each { |type| + TESTING.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| +TESTING.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] } + watch("#{type}/data/(.*)\.rb") { |match| + m1 = match[1] + run_matching_files("#{type}/#{m1}/#{m1}_#{type}.rb") + } +} + +%w[rb erb haml slim].each { |type| + watch(".*/(.*)\.#{type}") { |match| + run_matching_files(match[1]) + } } # Ctrl-\ or ctrl-4 Signal.trap('QUIT') { run_all_tests } # Ctrl-C