Posted over 8 years ago. Visible to the public.

Test a gem in multiple versions of Rails

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.

For best practice examples that give you full coverage with minimal repitition of code, check out our gems has_defaults and assignable_values. 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.
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Tobias Kraze
Last edit:
almost 7 years ago
Keywords:
multiple, versions
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more