class TestWatch
Public Class Methods
new(listen_to_relative_path, test_relative_path)
click to toggle source
# File lib/test_watch.rb, line 8 def initialize(listen_to_relative_path, test_relative_path) @listen_to_relative_path = listen_to_relative_path @test_relative_path = test_relative_path start end
Private Instance Methods
absolute_relative_path()
click to toggle source
# File lib/test_watch.rb, line 28 def absolute_relative_path File.expand_path(@listen_to_relative_path) end
absolute_test_path()
click to toggle source
# File lib/test_watch.rb, line 32 def absolute_test_path File.expand_path(@test_relative_path) end
current_time()
click to toggle source
# File lib/test_watch.rb, line 47 def current_time Time.new.inspect end
from_test_output()
click to toggle source
# File lib/test_watch.rb, line 51 def from_test_output test_paths .map { |path| "#{test_header_for path}:\n#{`#{RUBY} #{path}`}\n" } .join "" end
listener()
click to toggle source
# File lib/test_watch.rb, line 22 def listener Listen.to(absolute_relative_path) do run end end
put_lines(text_with_lines)
click to toggle source
# File lib/test_watch.rb, line 65 def put_lines(text_with_lines) lines = text_with_lines.split("\n") lines.each do |line| puts "#{line}" end end
run()
click to toggle source
# File lib/test_watch.rb, line 36 def run system "clear" or system "cls" puts test_runner_header + current_time puts put_lines from_test_output end
start()
click to toggle source
# File lib/test_watch.rb, line 16 def start run listener.start sleep end
test_header_for(path)
click to toggle source
# File lib/test_watch.rb, line 57 def test_header_for(path) path.split('/').last.split('.').first.capitalize end
test_paths()
click to toggle source
# File lib/test_watch.rb, line 43 def test_paths Dir["#{absolute_test_path}/**/*.test.rb"] end
test_runner_header()
click to toggle source
# File lib/test_watch.rb, line 61 def test_runner_header "Running tests: " end