Read more

Test a gem in multiple versions of Rails

Tobias Kraze
November 22, 2010Software engineer at makandra GmbH

Plugins (and gems) are typically tested using a complete sample rails application that lives in the spec folder of the plugin. If your gem is supposed to work with multiple versions of Rails, you might want to use to separate apps - one for each rails version.

Illustration online protection

Rails professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
Read more Show archive.org snapshot

For best practice examples that give you full coverage with minimal repitition of code, check out our gems has_defaults Show archive.org snapshot and assignable_values Show archive.org snapshot . In particular, take a look at:

  • Multiple spec_helper.rb and Rails apps in e.g. spec/rails-2.3 and spec/rails-3.0
  • The Rails apps share models, controllers (app/*) and migrations (db/*) with symlinks to spec/shared/app_root. The symlinks are checked into Git.
  • An own Gemfile for each Rails app, which freezes the correct versions of Rails and RSpec and referencing the gem itself.
  • Shared specs live in spec/shared/library_name.
  • A Rakefile in the project root that lets you run bundler (rake all:bundle) or specs (rake all:spec) on all projects, which pretty colored output.
Posted by Tobias Kraze to makandra dev (2010-11-22 17:13)