Skip to content

Instantly share code, notes, and snippets.

@duffyjp
Created November 12, 2015 16:58
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 duffyjp/af04132f7eb431626331 to your computer and use it in GitHub Desktop.
Save duffyjp/af04132f7eb431626331 to your computer and use it in GitHub Desktop.
Parallel Tests & Rspec shell script - Intelligently runs single spec with rspec or folder(s) / full suite with parallel_rspec. Shows nice summary at the end.
#!/bin/bash
start_time=`date +%s`
RAILS_ENV="test"
rm db/test.sqlite3*
if [[ $1 == *".rb"* ]]
then
echo "Testing with RSpec"
bundle exec rspec $1
else
echo "Testing with Parallel Tests"
bundle exec rake parallel:create # Create 0 byte sqlite file for each cpu core
bundle exec rake parallel:load_schema # Load schema ignoring development
if [[ $1 == "" ]]
then
parallel_rspec ./spec ./vendor/engines/compensation/spec
else
parallel_rspec $1
fi
fi
end_time=`date +%s`
time_elapsed=$(($end_time-$start_time))
echo "==============================================================================="
grep "rspec \./" tmp/failing_specs.log | sort -n
echo "Testing took $time_elapsed seconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment