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 book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
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)