Why isn't this performing a system command?
I've put this together through scripts that I have found online, but I'm not sure why my puts command is not performing a system command? It just sits in the terminal unexecuted. When I tried system ("rspec spec") it worked but I wasn't able to capture the output.
def run(cmd)
`#{cmd}`
end
def run_spec_files
system('clear')
result = "rspec spec"
puts result
growl(re开发者_如何学JAVAsult)
end
def growl(message)
growlnotify = `which growlnotify`.chomp
unless growlnotify.empty?
title = "Test Results"
options = "-w -n Watchr -m '#{message}' '#{title}'"
run("#{growlnotify} #{options} &")
end
end
watch( 'lib/(.*)\.rb' ) { run_spec_files }
puts
Just prints out the string you pass it. It doesn't execute it in a shell. Backticks like in your run
method will execute on the shell. Try this:
def run_spec_files
system('clear')
result = run("rspec spec")
puts result
growl(result)
end
精彩评论