Reputation: 16383
In a ruby file to be run from bash, I want to test that all my rspec
tests have passed. So I want something like
#!/usr/bin/env ruby
ls = `rspec spec`
if ls == 'passed' then do something
Is there an rspec
option or some other way to do this?
Upvotes: 1
Views: 44
Reputation: 230346
rspec
, like a good unix citizen, returns exit code 0 when all was good and a non-zero when there was an error.
You can use system
, it translates exit codes for you, and returns a boolean-ish value.
if system('rspec spec')
# all good
end
Also see this answer for more details: ruby system command check exit code
Upvotes: 4