开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜