Skip to content

Instantly share code, notes, and snippets.

@davidoram
Last active September 10, 2015 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidoram/4888723e6ec452769a9c to your computer and use it in GitHub Desktop.
Save davidoram/4888723e6ec452769a9c to your computer and use it in GitHub Desktop.
Given a list of specs, run one test together with each in the list
#!/bin/bash
#
# Run a failing spec in combination with each other spec and record which combinations cause a failure
#
# Put a list of all specs into specs.txt
# eg: $ $ find spec -name '*_spec.rb' -print > specs.txt
# Set the failingspec variable below
# Set the seed variable below
#
# Writes a log to testspec.log, which is formatted as follows:
# ...
# OK: ./spec/controllers/my_controller_spec.rb and ./spec/controllers/my_failing_spec.rb
# OK: ./spec/controllers/other_controller_spec.rb and ./spec/controllers/my_failing_spec.rb
# FAILED: ./spec/controllers/bad_controller_spec.rb and ./spec/controllers/my_failing_spec.rb
# ...
#
#
outfile=testspec.log
failingspec=./spec/controllers/burney/payments_controller_spec.rb
seed=34104
echo "Test run started" > $outfile
for spec in `cat specs.txt`
do
echo "Running $spec and $failingspec ..."
bundle exec rspec $spec $failingspec --seed $seed
rc=$?
if [[ $rc == 0 ]]
then
echo "OK: $spec and $failingspec" >> $outfile
else
echo "FAILED: $spec and $failingspec" >> $outfile
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment