The Blog
Testing Multiple Ruby Versions and Gemsets Using RVM
I think it might be all the time I’m devoting to L.A. Noire which caused me to want to research how to test multiple Ruby versions and gemsets using RVM, but that’s besides the point. Here’s how I went about it.
I’ve been testing this with 2 gems I maintain, tasty – a Ruby gem for interacting with the del.icio.us service and leaderboard – Leaderboards backed by Redis in Ruby. I’ll use tasty as the example for this blog post.
The .rvmrc file for the tasty gem looks like:
rvm --create 1.8.7@tasty_gemrvm --create 1.9.2@tasty_gem
In the Rakefile for the tasty gem I have the following:
task :default => :test_rubies
desc "Runs tests on Ruby 1.8.7 and 1.9.2"task :test_rubies do system "rvm 1.8.7@tasty_gem,1.9.2@tasty_gem rake test"end
If I run rake, I get the following output, correctly showing that rake uses the tasty_gem gemset for each version of Ruby.
fossil:tasty dczarnecki$ rake(in /Users/dczarnecki/projects/tasty)(in /Users/dczarnecki/projects/tasty)/Users/dczarnecki/.rvm/rubies/ruby-1.8.7-p302/bin/ruby -I"lib:lib:test" "/Users/dczarnecki/.rvm/gems/ruby-1.8.7-p302@tasty_gem/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/test_tasty.rb" Loaded suite /Users/dczarnecki/.rvm/gems/ruby-1.8.7-p302@tasty_gem/gems/rake-0.8.7/lib/rake/rake_test_loaderStarted......Finished in 0.003357 seconds.
6 tests, 8 assertions, 0 failures, 0 errors(in /Users/dczarnecki/projects/tasty)/Users/dczarnecki/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -I"lib:lib:test" "/Users/dczarnecki/.rvm/gems/ruby-1.9.2-p180@tasty_gem/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/test_tasty.rb" Loaded suite /Users/dczarnecki/.rvm/gems/ruby-1.9.2-p180@tasty_gem/gems/rake-0.8.7/lib/rake/rake_test_loaderStarted......Finished in 0.010221 seconds.
6 tests, 8 assertions, 0 failures, 0 errors, 0 skips
I also used “_gem” in the gemset names. Is that overkill? I was just trying to not conflict with say a project you might have called “tasty” with it’s own tasty gemset.
You can find more hilarity over on my Twitter account, CzarneckiD.






