简体   繁体   中英

How do I write a bash script to abort a rspec test if it fails

I am trying to write a script that prevents my applications from turning into WAR files if they do not pass an rspec test. So I am writing a bash script to do this. The code is wrong so please help.

CODE:
 bundle exec rspec spec/ --format documentation --fail-fast

#for i in spec/test_spec.rb
#do
if spec/ --fails-fast == true 
 then
        echo 'failed rspec test'
else
        echo "rspec test passed; Warbalize Now!!!!!"
fi
#done

You can just use normal exit codes, since bundle exec rspec will preserve the exit code from rspec . Eg

#!/bin/bash
if ! bundle exec rspec spec/ --format documentation --fail-fast; then
  echo "failed rspec test"
else
  echo "rspec test passed; Warbalize Now!!!!!"
fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM