我已经通过我在网上找到的脚本把这些放在一起了,但是我不确定为什么我的put命令没有执行系统命令?它只是停留在终端中,没有执行。当我尝试system ("rspec spec")时,它可以工作,但我无法捕获输出。
def run(cmd)
`#{cmd}`
end
def run_spec_files
system('clear')
result = "rspec spec"
puts result
growl(result)
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 }发布于 2011-04-09 02:12:41
puts只是打印出你传递的字符串。它不会在shell中执行它。像您的run方法中的反引号将在shell上执行。试试这个:
def run_spec_files
system('clear')
result = run("rspec spec")
puts result
growl(result)
endhttps://stackoverflow.com/questions/5599087
复制相似问题