How to start your RSpec / Cucumber / Spork / Watchr test environment with a single command
My Rails 3 test environment consists of RSpec, Cucumber, Spork and Watchr. Additonally I am running rails console and rails server. This means I have to spawn six terminals or on terminal with six tabs. My preferences lean towards the tab solution. I am setting this up just once or maybe twice a day, but in my humble opinion it is pretty annoying to do this by hand.
The first idea coming to mind might be to spawn multiple gnome-terminals in tabs and execute the desired command in each of them. Unfortunately you have to choose whether you would like to execute a command or rather have a bash shell available. If you just pass on the command to gnome-terminal it closes immediately after the command finished. I struggled a few minutes with this but finally I got it to work:
gnome-terminal --tab --title "spork rspec" -e "bash -c \"bundle exec spork rspec; exec bash\"" \
--tab --title "spork cucumber" -e "bash -c \"bundle exec spork cucumber; exec bash\"" \
--tab --title "watchr" -e "bash -c \"bundle exec watchr .watchr; exec bash\"" \
--tab --title "console" -e "bash -c \"rails c; exec bash\"" \
--tab --title "server" -e "bash -c \"rails s; exec bash\""
Just start bash, after the command finished and you are fine. Feels a little bit hacky but works as intended.
I put this into a file, made it executable and start it when I start working on my app. Awesome. Saves 30 seconds each day.
Have fun!
-
Josh Shupack
-
Anonymous


Hi,