I have the following Rakefile
desc "Runs tests"
namespace :test do
task :api do
`mocha`
end
end
When I run the command rake test:api
, I don't get the nice output of dots that I would if I just ran the command mocha
.
How do I print the output of a command real-time in a rake task?
You can just put
the output:
puts `mocha`
The backticks ` are calling the command mocha and return the output of the command.
You may also use %x{}
:
puts %x{mocha}
Or you use system
:
system('mocha')
Or you store the output for later use in a variable:
output = `mocha`
puts output