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 Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
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)