Sha256: ad4014a9844ef5e0779c21e322cb67c03d6b300a7d06491d8d99f7efae5a8f4e
Contents?: true
Size: 1.54 KB
Versions: 10
Compression:
Stored size: 1.54 KB
Contents
#watch( 'test/test_.*\.rb' ) {|md| system("rake test") } #watch( 'lib/(.*)\.rb' ) {|md| system("rake test") } def notify(message) notify_send = `which notify-send`.chomp title = "Watchr Test Results" image = message.include?('0 failures, 0 errors') ? '~/.autotest_images/pass.png' : '~/.autotest_images/fail.png' msg = message.slice(/(\d+)\stests,\s(\d+)\sassertions,\s(\d+)\sfailures,\s(\d+)\serrors/) system %Q{#{notify_send} '#{title}' '#{msg}' -i #{image} -t 2000 &} end def run(cmd) puts(cmd) `#{cmd}` end def run_test_file(file) system('clear') puts file result = run(%Q(ruby -I"lib:test" -rubygems #{file})) notify result.split("\n").last rescue nil puts result end def related_test_files(path) Dir['test/*.rb'].select { |file| file =~ /test_#{File.basename(path).split(".").first}.rb/ } end def run_all_tests system('clear') result = `rake test` notify result.split("\n").last rescue nil puts result end def run_validation_tests system('clear') result = `rake test:units TEST=test/test_validations.rb` notify result.split("\n").last rescue nil puts result end watch('test/helper\.rb') { run_all_tests } watch('test/test_.*\.rb') { run_all_tests } watch('lib/.*/.*\.rb') { run_all_tests } Signal.trap('QUIT') { run_all_tests } # Ctrl-\ # Ctrl-C Signal.trap 'INT' do if @interrupted then @wants_to_quit = true abort("\n") else puts "Interrupt a second time to quit" @interrupted = true Kernel.sleep 1.5 # raise Interrupt, nil # let the run loop catch it run_all_tests end end
Version data entries
10 entries across 10 versions & 1 rubygems