Sha256: f31b30dbc38a664ca4e0affb0ec0f98579f4c69dd1e5a3bc59b54fa7ea3d3aad

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

class AutoTest
	attr_accessor :run_at, :files

	def initialize
		@run_at = Time.new
		@files = File.find_java_files
	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 = TestRunner.run_test(test_class)
		TestRunner.run_all_tests if green
		reset 
	end
	
	def find_test_class(file)
		return file.split("/").last.split(".java").last.concat("Test.java") unless file.include? "Test.java"
		return file.split("/").last if file.include? "Test.java"
	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.1 lib/java_autotest/autotest.rb