1

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

test_script.rb

#!/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?

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.