Testing multiple Gemfiles and Rubies with WWTD (no Appraisal)

Problem
Testing against many gemfiles/rubies is painful, Appraisal offers a somewhat working solution but adds new steps/problems.

Solution
Use WWTD by using the gemspec for dependencies or a gemfiles/common.rb
(Also no longer runs gemfiles that are excluded in travis.yml)

Example PR

Usage

  • Run tests on all gemfiles: rake
  • Run tests on all gemfiles and all rubies: rake wwtd
  • Run tests on Gemfile: rake test

Code

# Gemfile
source "https://rubygems.org"
gemspec
gem "rails" # newest

# Rakefile
require 'wwtd/tasks'
task default: "wwtd:local"

# gemfiles/rails32.gemfile
source "https://rubygems.org"
gemspec path: "../"
gem "rails", "~> 3.2.18"

# gemfiles/rails40.gemfile
source "https://rubygems.org"
gemspec path: "../"
gem "rails", "~> 4.0.6"

# foo.gemspec
...
s.add_runtime_dependency "rails", ">= 3.2.18"

# .travis.yml
rvm:
  - 1.9.3
  - 2.0.0
  - 2.1.2
gemfile:
  - gemfiles/rails32.gemfile
  - gemfiles/rails40.gemfile
script: "rake test"

Git dependencies
Cannot be specified in gemspec, so we put them in a loadable file.

# all gemfiles
eval(File.read('gemfiles/common.rb'))

# gemfiles/common.rb
gem "foo", git: "https://github.com/bar/foo"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s