From c75ccb17a8bb9995843760cf187c46ce95bebcca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=B6ler?= Date: Tue, 10 Jun 2014 14:46:58 +0200 Subject: [PATCH] Improve Rakefile: prepare Rails 4.1 support with Travis CI --- .travis.yml | 1 + Rakefile | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b263067..cdc30e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: ruby rvm: - "1.8.7" - "1.9.3" + - "2.1.0" - ree services: - mysql diff --git a/Rakefile b/Rakefile index dc7a04f..c3d72eb 100644 --- a/Rakefile +++ b/Rakefile @@ -8,11 +8,13 @@ task :default => 'all:spec' namespace :travis do desc 'Run tests on Travis CI' - task :run => ['slimgems', 'all:bundle:install', 'all:spec'] + task :run => [:compatible_rubygems, 'all:bundle:install', 'all:spec'] - desc 'Install slimgems' - task :slimgems do - system('gem install slimgems') + desc 'Ensure compatible Rubygems version for Ruby 1.8' + task :compatible_rubygems do + if RUBY_VERSION == '1.8.7' + system "rvm rubygems latest-1.8 --force" + end end end @@ -29,13 +31,16 @@ namespace :all do fail "Tests failed" unless success end + + task :bundle => 'bundle:install' + namespace :bundle do desc "Bundle all spec apps" task :install do for_each_directory_of('spec/**/Gemfile') do |directory| Bundler.with_clean_env do - system("cd #{directory} && bundle install") + system("cd #{directory} && bundle install --without development") end end end @@ -56,7 +61,14 @@ end def for_each_directory_of(path, &block) Dir[path].sort.each do |rakefile| directory = File.dirname(rakefile) - puts '', "\033[44m#{directory}\033[0m", '' - block.call(directory) + puts '', "\033[4;34m# #{directory}\033[0m" # blue underline + + if directory.include?('rails-2.3') and RUBY_VERSION != '1.8.7' + puts 'Skipping - Rails 2.3 requires Ruby 1.8.7' + elsif directory.include?('rails-4.1') and RUBY_VERSION == '1.8.7' + puts 'Skipping - Rails 4.1 does not support Ruby 1.8' + else + block.call(directory) + end end end