Upgrade to Pro — share decks privately, control downloads, hide ads and more …

You have to test multiple versions of your gem'...

You have to test multiple versions of your gem's dependencies. You used Appraisal. It's super affective!

So, it seems like you've finished writing your awesome gem. However, are you sure that your gem is working perfectly against multiple versions of its dependency? Are you sure that you didn't break any backward compatibility? In this talk, I'm going to show you the approach we have been taken to test our gems against multiple versions of dependencies, such as testing against Rails 3.2 and Rails 3.1. I'm also going to introduce you to our gem called "Appraisal" which helps you generating Gemfiles to be used with Bundler, and also guide it to running your test suite against those multiple Gemfiles. Lastly, I'm going to show you how you can config Travis CI to test your gem against those multiple versions of dependencies.

Presented at RubyKaigi 2013 on May 30, 2013.

Video is available at http://vimeo.com/69748748

Prem Sichanugrist

May 30, 2013
Tweet

More Decks by Prem Sichanugrist

Other Decks in Programming

Transcript

  1. You have to test multiple versions of your gem’s dependencies.

    You used Appraisal. It’s super effective!
  2. ~>

  3. Why was this so bad? • Time consuming • Can’t

    test against multiple versions at once • Doesn’t handle dependency of dependency • Dependency hell • $ rm -Rf $GEM_HOME
  4. $ rvm gemset create rails-3-2 $ rvm gemset use rails-3-2

    $ gem install rails -v 3.2.13 $ rake $ rvm gemset create rails-3-1 $ rvm gemset use rails-3-1 $ gem install rails -v 3.1.12 $ rake # ...
  5. This is good, but ... • Waste of space; gems

    are not shared • Contributors need to use Ruby manager that supports Gemset • May need to have bootstrap script to setup gemsets
  6. $ bundle install --gemfile=rails-3-2.gemfile $ export BUNDLE_GEMFILE=rails-3-2.gemfile $ bundle exec

    rake $ bundle install --gemfile=rails-3-1.gemfile $ export BUNDLE_GEMFILE=rails-3-1.gemfile $ bundle exec rake
  7. # Run "test" task against all versions $ rake appraisal

    test # Run "test" task against a single version $ rake appraisal:rails-3-1 test
  8. Appraisal • Allow you to set dependencies in a single

    place • Generate sub-Gemfiles for you • Install multiple versions of dependencies • Setup Bundler to use the correct version of dependency