Skip to content

Commit

Permalink
Improve Rakefile: prepare Rails 4.1 support with Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
codener committed Jun 10, 2014
1 parent 3def878 commit c75ccb1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -2,6 +2,7 @@ language: ruby
rvm:
- "1.8.7"
- "1.9.3"
- "2.1.0"
- ree
services:
- mysql
Expand Down
26 changes: 19 additions & 7 deletions Rakefile
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit c75ccb1

Please sign in to comment.