Sha256: b1a3681ed61920c3a9c43f2106fa5a928fff028e08e341eedbffd047151a4f6b

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

class AutoTest
  attr_accessor :run_at, :files, :test_runner

  def initialize
    @files = File.find_java_files
    @test_runner = TestRunner.new
    @test_runner.run_all_tests
    @run_at = Time.new
  end	

  def listen
    @files.each do |file|
      if (File.atime(file).to_i > @run_at.to_i)
        run(file) 
        break
      end
    end
    true
  end

  def run(file)
    test_class = find_test_class file
    puts "Running test to #{test_class}."
    green = @test_runner.run_test(test_class)
    @test_runner.run_all_tests if green
    reset 
  end

  def find_test_class(file)
    return file.split("/").last.split(".java").last.concat("Test") unless file.include? "Test.java"
    file.split("/").last.split(".").first
  end

  def reset
    @run_at = Time.new
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
java-autotest-0.0.2 lib/java_autotest/autotest.rb