I found myself writting a gem for internal use that needed to run in several different ruby versions and MRI. In addition, the projects that it would be used in had other dependencies which also meant that it would need to function with different versions of dependencies. Here is how I ensured I was testing all scenarios.
Testing Multiple Ruby Versions
I started by leveraging rvm, which I use to manage multiple ruby versions on my development machine.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
The script basically just runs rspec on several versions of ruby. I used
set -e to stop execution of the script if any commands has an exit code different than 0.
Testing Multiple Gem Versions
The next piece of the puzzle is the Appraisal gem from the guys at thoughbot. This gem lets you test your gem against different versions of dependencies. It is really elegant, and the instructions on the project page are really easy to follow. My Appraisals files like:
1 2 3 4 5 6 7
All Together Now
As a last step, I just modified my first script to use appraisals, so I now run all gem dependency variations against all rubies.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Simple, yet effective.