Module: Keeptesting::CLI

Defined in:
lib/keeptesting/cli.rb

Constant Summary collapse

GREEN_TEXT =
"\033[32m"
YELLOW_TEXT =
"\033[33m"
RED_TEXT =
"\033[31m"
RESET_TEXT =
"\033[0m"

Class Method Summary collapse

Class Method Details

.start_test_loop(options) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/keeptesting/cli.rb', line 29

def self.start_test_loop(options)
  Keeptesting::CLI::testrun(options)
  FSSM.monitor do
    options[:watched_paths].each do |watched_path|
      path watched_path do
        update {|base, relative| Keeptesting::CLI::testrun(options)}
        delete {|base, relative| Keeptesting::CLI::testrun(options)}
        create {|base, relative| Keeptesting::CLI::testrun(options)}
      end
    end
  end
end

.testrun(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/keeptesting/cli.rb', line 12

def self.testrun(options)
  puts `clear`
  puts "#{YELLOW_TEXT}RUNNING TESTS...#{RESET_TEXT}"
  
  cmd = options[:test_command]
  test_output = `#{cmd} 2>&1`
  test_succeded = Keeptesting::Common::test_success?(test_output, options[:failure_regex])
  puts `clear`
  if test_succeded
    puts "#{GREEN_TEXT}SUCCESS!#{RESET_TEXT}\n\n\n"
  else
    puts "#{RED_TEXT}FAILURE!#{RESET_TEXT}\n\n\n"
  end

  puts test_output
end