Class: Providence::BaseWatchr

Inherits:
Object
  • Object
show all
Defined in:
lib/providence/base_watchr.rb

Direct Known Subclasses

CucumberWatchr, RspecWatchr

Class Method Summary collapse

Class Method Details

.alert_messageObject



38
# File 'lib/providence/base_watchr.rb', line 38

def alert_message; 'Cannot determine test status'; end

.fail_messageObject



36
# File 'lib/providence/base_watchr.rb', line 36

def fail_message; 'Failed'; end

.pass_messageObject



35
# File 'lib/providence/base_watchr.rb', line 35

def pass_message; 'Passed'; end

.pending_messageObject



37
# File 'lib/providence/base_watchr.rb', line 37

def pending_message; 'Pending further work'; end

.run(path) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/providence/base_watchr.rb', line 4

def run(path)  
  cmd = "#{command} #{path}"
  
  Eye.growl "Running #{name}"
  system('clear')
  puts(cmd)
  
  status = parse_test_status(run_command(cmd))
  Eye.growl send("#{status}_message".to_sym), Eye.send("#{status}_image".to_sym)
end

.run_command(cmd) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/providence/base_watchr.rb', line 15

def run_command(cmd)
  last_output = []
  stdin, stdout, stderr = Open3.popen3(cmd)
  while !stdout.eof? || !stderr.eof
    err = stderr.gets
    puts err unless err.nil? || err.strip.empty?
    
    line = stdout.gets
    last_output.replace([]) if line.nil? || line.strip.empty?
    last_output.push(line)
    puts line         
  end

  stdin.close
  stdout.close
  stderr.close
  
  last_output
end