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 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
andspec/rails-3.0
- The Rails apps share models, controllers (
app/*
) and migrations (db/*
) with symlinks tospec/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 16:13)