lib/rspactor/interactor.rb in guillaumegentil-rspactor-0.4.1 vs lib/rspactor/interactor.rb in guillaumegentil-rspactor-0.4.2

- old
+ new

@@ -1,19 +1,21 @@ require 'timeout' module RSpactor class Interactor - def initialize(dir, options = {}) - @root = dir - @options = options + + attr_reader :runner + + def initialize(runner) + @runner = runner ticker end - def wait_for_enter_key(msg, seconds_to_wait, clear = false) + def wait_for_enter_key(msg, seconds_to_wait) begin Timeout::timeout(seconds_to_wait) do - system("clear;") if clear + system("clear;") if runner.options[:clear] ticker(:start => true, :msg => msg) $stdin.gets return true end rescue Timeout::Error @@ -26,16 +28,23 @@ def start_termination_handler @main_thread = Thread.current Thread.new do loop do sleep 0.5 - if $stdin.gets - if wait_for_enter_key("** Running all specs.. Hit <enter> again to exit RSpactor", 3, @options[:clear]) - @main_thread.exit - exit + if entry = $stdin.gets + case entry + when "c\n" # Cucumber: current tagged feature + runner.run_cucumber_command + when "ca\n" # Cucumber All: ~pending tagged feature + runner.run_cucumber_command('~pending') + else + if wait_for_enter_key("** Running all specs.. Hit <enter> again to exit RSpactor", 1) + @main_thread.exit + exit + end + runner.run_all_specs end - Runner.new(@root).run_all_specs end end end end @@ -55,10 +64,10 @@ sleep 1.0 end end end end - + def write(msg) $stdout.print(msg) $stdout.flush end end \ No newline at end of file