Skip to content

Commit

Permalink
support testing on multiple rubies with rbenv
Browse files Browse the repository at this point in the history
  • Loading branch information
robertzx committed Oct 5, 2013
1 parent 38589fd commit 689797f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,38 @@ require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

namespace :spec do
SPEC_PLATFORMS = ENV.has_key?('SPEC_PLATFORMS') ?
ENV['SPEC_PLATFORMS'].split(/ +/) :
%w{1.9.3-p448 2.0.0-p247 1.8.7-p374}

desc "Run on three Rubies"
task :platforms do
current = %x{rvm-prompt v}

# current = %x[rbenv version | awk '{print $1}']
fail = false
%w{1.8.7 1.9.2}.each do |version|
SPEC_PLATFORMS.each do |version|
puts "Switching to #{version}"
Bundler.with_clean_env do
system %{bash -c 'source ~/.rvm/scripts/rvm && rvm #{version} && bundle exec rake spec'}
system %{bash -c 'eval "$(rbenv init -)" && rbenv use #{version} && rbenv rehash && ruby -v && bundle exec rake spec'}
end
if $?.exitstatus != 0
fail = true
break
end
end

system %{rvm #{current}}

exit (fail ? 1 : 0)
end

desc 'Install gems for all tested rubies'
task :platform_setup do
SPEC_PLATFORMS.each do |version|
puts "Setting up platform #{version}"
Bundler.with_clean_env do
system %{bash -c 'eval "$(rbenv init -)" && rbenv use #{version} && rbenv rehash && gem install bundler && bundle install'}
end
end
end
end


Expand Down

0 comments on commit 689797f

Please sign in to comment.