Permalink
Browse files

More robust scripts, rake tasks and gemfile to run tests against majo…

…rs rails versions.

* Rakefile and script/use_rails exit or raise if something go wrong when
running a command.
* Gemfile supports rails versions with 2 digits patch level
* Always bundle when changing rails version!
  • Loading branch information...
1 parent 2e3a187 commit 5722d76961bdbbfede3ce7a7316f3b2d865e3a91 @pcreux pcreux committed Aug 15, 2011
Showing with 20 additions and 19 deletions.
  1. +8 −5 Gemfile
  2. +2 −11 Rakefile
  3. +2 −1 script/use_rails
  4. +8 −2 tasks/test.rake
View
13 Gemfile
@@ -4,18 +4,21 @@ gemspec
require File.expand_path('../spec/support/detect_rails_version', __FILE__)
-case ENV['RAILS'] || detect_rails_version
-when /3.0.(\d)*/
- gem 'rails', "= 3.0.#{$1}"
+rails_version = ENV['RAILS'] || detect_rails_version || "3.1.0.rc10"
+gem 'rails', rails_version
+
+case rails_version
+when /^3\.0/
gem "meta_search", '~> 1.0.0'
-when /3.1.(.*)/
- gem 'rails', "= 3.1.#{$1}"
+when /^3\.1/
gem "meta_search", '>= 1.1.0.pre'
gem "uglifier"
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-script'
gem 'execjs'
gem 'therubyracer'
+else
+ raise "Rails #{rails_version} is not supported yet"
end
group :development, :test do
View
@@ -6,7 +6,7 @@ require 'rake'
def cmd(command)
puts command
- system command
+ raise unless system command
end
require File.expand_path('../spec/support/detect_rails_version', __FILE__)
@@ -15,13 +15,4 @@ require File.expand_path('../spec/support/detect_rails_version', __FILE__)
FileList['tasks/**/*.rake'].each { |task| import task }
# Run the specs & cukes
-task :default do
- # Force spec files to be loaded and ran in alphabetical order.
- specs_unit = Dir['spec/unit/**/*_spec.rb'].sort.join(' ')
- specs_integration = Dir['spec/integration/**/*_spec.rb'].sort.join(' ')
- exit [
- cmd("export RAILS=3.0.5 && export RAILS_ENV=test && bundle exec rspec #{specs_unit}"),
- cmd("export RAILS=3.0.5 && export RAILS_ENV=test && bundle exec rspec #{specs_integration}"),
- cmd("export RAILS=3.0.5 && export RAILS_ENV=cucumber && bundle exec cucumber features"),
- ].uniq == [true]
-end
+task :default => :test
View
@@ -6,7 +6,7 @@
def cmd(command)
puts command
- system command
+ exit 1 unless system command
end
version = ARGV[0]
@@ -43,3 +43,4 @@ end
cmd("rm Gemfile.lock") if file_or_symlink?("Gemfile.lock")
cmd("ln -s #{gem_lock_file} Gemfile.lock")
+cmd("bundle")
View
@@ -9,19 +9,25 @@ namespace :test do
desc "Run against the important versions of rails"
task :major_rails_versions do
current_version = detect_rails_version if File.exists?("Gemfile.lock")
- ["3.0.7", "3.1.0.rc4"].each do |version|
+ ["3.0.10", "3.1.0.rc6"].each do |version|
puts
puts
puts "== Using Rails #{version}"
cmd "./script/use_rails #{version}"
cmd "bundle exec rspec spec"
cmd "bundle exec cucumber features"
end
- cmd "./script/use_rails #{current_version}"
+ cmd "./script/use_rails #{current_version}" if current_version
end
end
+# Run specs and cukes
+task :test do
+ cmd "bundle exec rspec spec"
+ cmd "bundle exec cucumber features"
+end
+
namespace :spec do
desc "Run specs for all versions of rails"
task :all do

0 comments on commit 5722d76

Please sign in to comment.