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 (optional for git: 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"