Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple-gemfile testing and travis configuration #240

Merged
merged 2 commits into from
Mar 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ coverage
.rvmrc
Gemfile.lock
.cucumber.rerun
gemfiles/*.lock
25 changes: 23 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
rvm:
- 1.9.3
- 2.0.0

# whitelist
branches:
only:
- master
# Needed for selenium browser
before_script: sh -e /etc/init.d/xvfb start

gemfile:
- gemfiles/rails_3_0.gemfile
- gemfiles/rails_3_1.gemfile
- gemfiles/rails_3_2.gemfile
- gemfiles/capybara_1_1.gemfile

matrix:
exclude:
- rvm: 2.0.0
gemfile: gemfiles/rails_3_0.gemfile
- rvm: 2.0.0
gemfile: gemfiles/rails_3_1.gemfile
- rvm: 2.0.0
gemfile: gemfiles/capybara_1_1.gemfile

services:
- mongodb

# Needed for selenium browser
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"

notifications:
email:
- [email protected]
Expand Down
53 changes: 53 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
appraise "rails_3_0" do
gem "rails", "~> 3.0.20"
gem "capybara", "~> 2.0.2"
gem "turn"
gem "rspec-rails"
gem "jquery-rails"
gem "uglifier"
gem "sqlite3"
gem "bson_ext"
gem "mongoid"
end

appraise "rails_3_1" do
gem "rails", "~> 3.1.11"
gem "capybara", "~> 2.0.2"
gem 'turn'
gem 'rspec-rails'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'jquery-rails'
gem 'sqlite3'
gem 'bson_ext'
gem 'mongoid'
end

appraise "rails_3_2" do
gem "rails", "~> 3.2.12"
gem "capybara", "~> 2.0.2"
gem 'turn'
gem 'rspec-rails'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'jquery-rails'
gem 'sqlite3'
gem 'bson_ext'
gem 'mongoid'
end

appraise "capybara_1_1" do
gem "capybara", "~> 1.1.2"
gem "rails", "~> 3.2.12"
gem 'turn'
gem 'rspec-rails'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'jquery-rails'
gem 'sqlite3'
gem 'bson_ext'
gem 'mongoid'
end
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
source "https://rubygems.org"

# Test dependencies for Rails in the default test task, as test-generated
# apps do not run bundler for speed reasons. Kept here so they can be
# excluded from Appraisal-generated gemfiles.
gem 'rails', '~> 3.2.12'
gem 'turn'
gem 'rspec-rails'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'jquery-rails'
gem 'sqlite3'
gem 'bson_ext'
gem 'mongoid'

gemspec
3 changes: 3 additions & 0 deletions Gemfile.appraisal
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gemspec
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,25 @@ I strongly recommend rvm and ruby 1.9.3. When you have that, cd into your cucumb
gem install bundler
bundle install

### Running all features
### Running all tests

With all dependencies installed, all features should pass:
With all dependencies installed, all specs and features should pass:

rake cucumber
rake

One of the features uses MongoDB, which needs to be running in order to make features/mongoid.feature to pass.

### Running Appraisal suite

In order to test against multiple versions of key dependencies, the [Appraisal](https://github.com/thoughtbot/appraisal) is used to generate multiple gemfiles, stored in the `gemfiles/` directory. Normally these will only run on Travis; however, if you want to run the full test suite against all gemfiles, run the following commands:

rake gemfiles:install
rake test:all

To run the suite against a named gemfile, use the following:

rake test:gemfile[rails_3_0]

To remove and rebuild the different gemfiles (for example, to update a rails version or its dependencies), use the following:

rake gemfiles:rebuild
47 changes: 34 additions & 13 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
# encoding: utf-8
CUCUMBER_RAILS_VERSION = Gem::Specification.load(File.dirname(__FILE__) + '/cucumber-rails.gemspec').version.version
require 'rubygems'
require 'bundler'
require 'bundler/setup'
require 'appraisal'
require 'rdoc' # https://github.com/lsegal/yard/commit/b861dcc2d7f7e1fbbed7b552ac2e4f7caf68bafa
require 'rake/clean'
require 'bundler'
require 'pathname'
Bundler::GemHelper.install_tasks

$:.unshift(File.dirname(__FILE__) + '/lib')
Dir["#{File.dirname(__FILE__)}/dev_tasks/*.rake"].sort.each { |ext| load ext }

CLEAN.include('doc', 'tmp')

# Needed for selenium browser
# See http://about.travis-ci.org/docs/user/selenium-setup/
task :travis do
["rspec spec", "rake cucumber"].each do |cmd|
puts "Starting to run #{cmd}..."
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
raise "#{cmd} failed!" unless $?.exitstatus == 0
task :default => :test

task :test => [:spec, :cucumber]

namespace :test do
desc "Run tests against all gemfiles"
task :all do
Rake::Task['appraisal'].invoke('test')
end

desc "Run tests against specified gemfile, e.g. rake test:gemfile[rails_3_0]"
task :gemfile, :name do |task, args|
unless args.name && Pathname.new("gemfiles/#{args.name}.gemfile").exist?
raise ArgumentError "You must provide the name of an existing Appraisal gemfile, e.g. 'rake test:gemfile[rails_3_2]'"
end
Rake::Task["appraisal:#{args.name}"].invoke('test')
end
end

if ENV['TRAVIS']
task :default => :travis
else
task :default => [:spec, :cucumber]
end
namespace :gemfiles do
desc "Install dependencies for all gemfiles"
task :install do
ENV['BUNDLE_GEMFILE'] = "Gemfile.appraisal"
Rake::Task['appraisal:install'].invoke
end

task :clean do
FileUtils.rm_rf("gemfiles/*")
end

desc "Rebuild generated gemfiles and install dependencies"
task :rebuild => [:clean, :install]
end
16 changes: 4 additions & 12 deletions cucumber-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,17 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('cucumber', '>= 1.2.0')
s.add_runtime_dependency('nokogiri', '>= 1.5.0')
s.add_runtime_dependency('capybara', '>= 1.1.2')
s.add_development_dependency('rails', '>= 3.2.3')
s.add_runtime_dependency('rails', '~> 3.0')

# Main development dependencies
s.add_development_dependency('rake', '>= 0.9.2.2')
s.add_development_dependency('bundler', '>= 1.1.0')
s.add_development_dependency('aruba', '>= 0.4.11')
s.add_development_dependency('sqlite3', '>= 1.3.6')
s.add_development_dependency('rspec', '~> 2.10.0')
s.add_development_dependency('rspec-rails', '~> 2.10.1')
s.add_development_dependency('ammeter', '>= 0.2.5')
s.add_development_dependency('factory_girl', '>= 3.2.0')
s.add_development_dependency('database_cleaner', '>= 0.7.2')
s.add_development_dependency('mongoid', '>= 2.4.9')
s.add_development_dependency('bson_ext', '>= 1.6.2')

# Various Stuff that Rails 3.1 puts inside apps.
s.add_development_dependency('turn', '>= 0.9.5')
s.add_development_dependency('sass-rails', '>= 3.2.5')
s.add_development_dependency('coffee-rails', '>= 3.2.2')
s.add_development_dependency('uglifier', '>= 1.2.4')
s.add_development_dependency('jquery-rails', '>= 2.0.2')
s.add_development_dependency('appraisal', '~> 0.5.1')

# For Documentation:
s.add_development_dependency('yard', '~> 0.8.1')
Expand Down
17 changes: 17 additions & 0 deletions gemfiles/capybara_1_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "capybara", "~> 1.1.2"
gem "rails", "~> 3.2.12"
gem "turn"
gem "rspec-rails"
gem "sass-rails"
gem "coffee-rails"
gem "uglifier"
gem "jquery-rails"
gem "sqlite3"
gem "bson_ext"
gem "mongoid"

gemspec :path=>"../"
15 changes: 15 additions & 0 deletions gemfiles/rails_3_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 3.0.20"
gem "capybara", "~> 2.0.2"
gem "turn"
gem "rspec-rails"
gem "jquery-rails"
gem "uglifier"
gem "sqlite3"
gem "bson_ext"
gem "mongoid"

gemspec :path=>"../"
17 changes: 17 additions & 0 deletions gemfiles/rails_3_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 3.1.11"
gem "capybara", "~> 2.0.2"
gem "turn"
gem "rspec-rails"
gem "sass-rails"
gem "coffee-rails"
gem "uglifier"
gem "jquery-rails"
gem "sqlite3"
gem "bson_ext"
gem "mongoid"

gemspec :path=>"../"
17 changes: 17 additions & 0 deletions gemfiles/rails_3_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 3.2.12"
gem "capybara", "~> 2.0.2"
gem "turn"
gem "rspec-rails"
gem "sass-rails"
gem "coffee-rails"
gem "uglifier"
gem "jquery-rails"
gem "sqlite3"
gem "bson_ext"
gem "mongoid"

gemspec :path=>"../"