Add Appraisals to the project to handle testing against multiple Rails version

Note that we also bump RSpec to 2.6.1.beta1 because the incompatibility with Rails 3.1.0.rc1
This commit is contained in:
Prem Sichanugrist 2011-05-25 14:38:07 -04:00
parent 224f2e5a70
commit 44847c6a87
11 changed files with 360 additions and 25 deletions

8
Appraisals Normal file
View File

@ -0,0 +1,8 @@
appraise "rails30" do
gem "rails", "3.0.3"
gem "rake", "~> 0.8.7"
end
appraise "rails31" do
gem "rails", "3.1.0.rc1"
end

View File

@ -1,4 +1,5 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gemspec gemspec
gem 'rake', '~> 0.8.7'

View File

@ -5,6 +5,7 @@ require 'rake/rdoctask'
require 'rake/gempackagetask' require 'rake/gempackagetask'
require 'rspec/core/rake_task' require 'rspec/core/rake_task'
require 'cucumber/rake/task' require 'cucumber/rake/task'
require 'appraisal'
$LOAD_PATH.unshift("lib") $LOAD_PATH.unshift("lib")
require 'shoulda/matchers/version' require 'shoulda/matchers/version'
@ -41,10 +42,14 @@ desc "Clean files generated by rake tasks"
task :clobber => [:clobber_rdoc, :clobber_package] task :clobber => [:clobber_rdoc, :clobber_package]
Cucumber::Rake::Task.new do |t| Cucumber::Rake::Task.new do |t|
t.fork = true t.fork = false
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')] t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
end end
desc 'Default: run specs and cucumber features' desc 'Default: run specs and cucumber features'
task :default => [:spec, :cucumber] task :default => [:all]
desc 'Test the plugin under all supported Rails versions.'
task :all, "appraisal:install" do |t|
exec('rake appraisal spec cucumber')
end

View File

@ -1,4 +1,3 @@
@disable-bundler
Feature: integrate with Rails Feature: integrate with Rails
Background: Background:
@ -13,7 +12,7 @@ Feature: integrate with Rails
end end
end end
""" """
When I successfully run "rake db:migrate --trace" When I successfully run `bundle exec rake db:migrate --trace`
And I write to "app/models/user.rb" with: And I write to "app/models/user.rb" with:
""" """
class User < ActiveRecord::Base class User < ActiveRecord::Base
@ -55,7 +54,7 @@ Feature: integrate with Rails
should assign_to(:example) should assign_to(:example)
end end
""" """
When I successfully run "rake test TESTOPTS=-v --trace" When I successfully run `bundle exec rake test TESTOPTS=-v --trace`
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors" Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
And the output should contain "2 tests, 2 assertions, 0 failures, 0 errors" And the output should contain "2 tests, 2 assertions, 0 failures, 0 errors"
And the output should contain "User should require name to be set" And the output should contain "User should require name to be set"
@ -82,7 +81,7 @@ Feature: integrate with Rails
it { should assign_to(:example) } it { should assign_to(:example) }
end end
""" """
When I successfully run "rake spec SPEC_OPTS=-fs --trace" When I successfully run `bundle exec rake spec SPEC_OPTS=-fs --trace`
Then the output should contain "2 examples, 0 failures" Then the output should contain "2 examples, 0 failures"
And the output should contain "should require name to be set" And the output should contain "should require name to be set"
And the output should contain "should assign @example" And the output should contain "should assign @example"

View File

@ -1,39 +1,44 @@
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
APP_NAME = 'testapp'.freeze APP_NAME = 'testapp'.freeze
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE)
ORIGINAL_BUNDLE_VARS = ENV.select{ |key,value| BUNDLE_ENV_VARS.include?(key) }
After do
ORIGINAL_BUNDLE_VARS.each_pair do |key, value|
ENV[key] = value
end
end
When /^I generate a new rails application$/ do When /^I generate a new rails application$/ do
steps %{ steps %{
When I run "rails _3.0.3_ new #{APP_NAME}" When I run `rails new #{APP_NAME}`
And I cd to "#{APP_NAME}" And I cd to "#{APP_NAME}"
And I write to "Gemfile" with: And I append gems from Appraisal Gemfile
""" And I reset Bundler environment variable
source "http://rubygems.org" And I successfully run `bundle install --local`
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
"""
And I successfully run "bundle install --local"
} }
end end
When /^I configure the application to use "([^\"]+)" from this project$/ do |name| When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'" append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'"
steps %{And I run "bundle install --local"} steps %{And I run `bundle install --local`}
end end
When /^I run the rspec generator$/ do When /^I run the rspec generator$/ do
steps %{ steps %{
When I successfully run "rails generate rspec:install" When I successfully run `rails generate rspec:install`
} }
end end
When /^I configure the application to use rspec\-rails$/ do When /^I configure the application to use rspec\-rails$/ do
append_to_gemfile "gem 'rspec-rails'" append_to_gemfile "gem 'rspec-rails', '~> 2.6.1.beta1'"
steps %{And I run "bundle install --local"} steps %{And I run `bundle install --local`}
end end
When /^I configure the application to use shoulda-context$/ do When /^I configure the application to use shoulda-context$/ do
append_to_gemfile "gem 'shoulda-context', :git => 'git@github.com:thoughtbot/shoulda-context.git'" append_to_gemfile "gem 'shoulda-context', :git => 'git@github.com:thoughtbot/shoulda-context.git'"
steps %{And I run "bundle install --local"} steps %{And I run `bundle install --local`}
end end
When /^I configure a wildcard route$/ do When /^I configure a wildcard route$/ do
@ -47,7 +52,21 @@ When /^I configure a wildcard route$/ do
} }
end end
module AppendHelpers When /^I append gems from Appraisal Gemfile$/ do
File.read(ENV['BUNDLE_GEMFILE']).split(/\n/).each do |line|
if line =~ /^gem "(?!rails|appraisal)/
append_to_gemfile line.strip
end
end
end
When /^I reset Bundler environment variable$/ do
BUNDLE_ENV_VARS.each do |key|
ENV[key] = nil
end
end
module FileHelpers
def append_to(path, contents) def append_to(path, contents)
in_current_dir do in_current_dir do
File.open(path, "a") do |file| File.open(path, "a") do |file|
@ -62,4 +81,4 @@ module AppendHelpers
end end
end end
World(AppendHelpers) World(FileHelpers)

8
gemfiles/rails30.gemfile Normal file
View File

@ -0,0 +1,8 @@
# This file was generated by Appraisal
source "http://rubygems.org"
gem "rake", "~> 0.8.7"
gem "rails", "3.0.3"
gemspec :path=>"/Users/sikachu/Projects/shoulda-matchers"

View File

@ -0,0 +1,137 @@
PATH
remote: /Users/sikachu/Projects/shoulda-matchers
specs:
shoulda-matchers (1.0.0.beta3)
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
appraisal (0.3.2)
aruba (~> 0.3.6)
bundler
rake
archive-tar-minitar (0.5.2)
arel (2.0.10)
aruba (0.3.6)
childprocess (>= 0.1.7)
cucumber (>= 0.10.0)
rspec (>= 2.5.0)
builder (2.1.2)
childprocess (0.1.9)
ffi (~> 1.0.6)
columnize (0.3.2)
cucumber (0.10.3)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (>= 2.3.8)
json (>= 1.4.6)
term-ansicolor (>= 1.0.5)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
ffi (1.0.9)
gherkin (2.3.9)
json (>= 1.4.6)
i18n (0.6.0)
json (1.5.1)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mocha (0.9.12)
polyglot (0.3.1)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.3)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rspec-rails (2.6.1.beta1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
term-ansicolor (1.0.5)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.27)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.3.1)
cucumber (~> 0.10.0)
mocha (~> 0.9.10)
rails (= 3.0.3)
rake (~> 0.8.7)
rspec-rails (~> 2.6.1.beta1)
ruby-debug19 (~> 0.11.6)
shoulda-matchers!
sqlite3-ruby (~> 1.3.2)

8
gemfiles/rails31.gemfile Normal file
View File

@ -0,0 +1,8 @@
# This file was generated by Appraisal
source "http://rubygems.org"
gem "rake", "~> 0.8.7"
gem "rails", "3.1.0.rc1"
gemspec :path=>"/Users/sikachu/Projects/shoulda-matchers"

View File

@ -0,0 +1,151 @@
PATH
remote: /Users/sikachu/Projects/shoulda-matchers
specs:
shoulda-matchers (1.0.0.beta3)
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.0.rc1)
actionpack (= 3.1.0.rc1)
mail (~> 2.3.0)
actionpack (3.1.0.rc1)
activemodel (= 3.1.0.rc1)
activesupport (= 3.1.0.rc1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6.0beta1)
rack (~> 1.3.0.beta2)
rack-cache (~> 1.0.1)
rack-mount (~> 0.8.1)
rack-test (~> 0.6.0)
sprockets (~> 2.0.0.beta.5)
tzinfo (~> 0.3.27)
activemodel (3.1.0.rc1)
activesupport (= 3.1.0.rc1)
bcrypt-ruby (~> 2.1.4)
builder (~> 3.0.0)
i18n (~> 0.6.0beta1)
activerecord (3.1.0.rc1)
activemodel (= 3.1.0.rc1)
activesupport (= 3.1.0.rc1)
arel (~> 2.1.1)
tzinfo (~> 0.3.27)
activeresource (3.1.0.rc1)
activemodel (= 3.1.0.rc1)
activesupport (= 3.1.0.rc1)
activesupport (3.1.0.rc1)
multi_json (~> 1.0)
appraisal (0.3.2)
aruba (~> 0.3.6)
bundler
rake
archive-tar-minitar (0.5.2)
arel (2.1.1)
aruba (0.3.6)
childprocess (>= 0.1.7)
cucumber (>= 0.10.0)
rspec (>= 2.5.0)
bcrypt-ruby (2.1.4)
builder (3.0.0)
childprocess (0.1.9)
ffi (~> 1.0.6)
columnize (0.3.2)
cucumber (0.10.3)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (>= 2.3.8)
json (>= 1.4.6)
term-ansicolor (>= 1.0.5)
diff-lcs (1.1.2)
erubis (2.7.0)
ffi (1.0.9)
gherkin (2.3.9)
json (>= 1.4.6)
hike (1.0.0)
i18n (0.6.0)
json (1.5.1)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mocha (0.9.12)
multi_json (1.0.3)
polyglot (0.3.1)
rack (1.3.0)
rack-cache (1.0.2)
rack (>= 0.4)
rack-mount (0.8.1)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.0)
rack (>= 1.0)
rails (3.1.0.rc1)
actionmailer (= 3.1.0.rc1)
actionpack (= 3.1.0.rc1)
activerecord (= 3.1.0.rc1)
activeresource (= 3.1.0.rc1)
activesupport (= 3.1.0.rc1)
bundler (~> 1.0)
railties (= 3.1.0.rc1)
railties (3.1.0.rc1)
actionpack (= 3.1.0.rc1)
activesupport (= 3.1.0.rc1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
thor (~> 0.14.6)
rake (0.8.7)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.3)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rspec-rails (2.6.1.beta1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
sprockets (2.0.0.beta.8)
hike (~> 1.0)
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
term-ansicolor (1.0.5)
thor (0.14.6)
tilt (1.3.1)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.27)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.3.1)
cucumber (~> 0.10.0)
mocha (~> 0.9.10)
rails (= 3.1.0.rc1)
rake (~> 0.8.7)
rspec-rails (~> 2.6.1.beta1)
ruby-debug19 (~> 0.11.6)
shoulda-matchers!
sqlite3-ruby (~> 1.3.2)

View File

@ -1,5 +1,5 @@
module Shoulda module Shoulda
module Matchers module Matchers
VERSION = "1.0.0.beta2".dup VERSION = "1.0.0.beta3".dup
end end
end end

View File

@ -19,12 +19,11 @@ Gem::Specification.new do |s|
s.summary = %q{Making tests easy on the fingers and eyes} s.summary = %q{Making tests easy on the fingers and eyes}
s.description = %q{Making tests easy on the fingers and eyes} s.description = %q{Making tests easy on the fingers and eyes}
s.add_development_dependency("rails", "3.0.3")
s.add_development_dependency("sqlite3-ruby", "~> 1.3.2") s.add_development_dependency("sqlite3-ruby", "~> 1.3.2")
s.add_development_dependency("mocha", "~> 0.9.10") s.add_development_dependency("mocha", "~> 0.9.10")
s.add_development_dependency("rspec-rails", "~> 2.3.0") s.add_development_dependency("rspec-rails", "~> 2.6.1.beta1")
s.add_development_dependency("cucumber", "~> 0.10.0") s.add_development_dependency("cucumber", "~> 0.10.0")
s.add_development_dependency("aruba", "~> 0.2.7") s.add_development_dependency("appraisal", "~> 0.3.1")
if RUBY_VERSION >= "1.9" if RUBY_VERSION >= "1.9"
s.add_development_dependency("ruby-debug19", "~> 0.11.6") s.add_development_dependency("ruby-debug19", "~> 0.11.6")