Skip to content

Commit

Permalink
Added support for testing multiple RubyGems
Browse files Browse the repository at this point in the history
Adds a :setup task to rakefile.rb that uses environment variables to
determine which version of RubyGems the tests should be run against.

    USE_RUBYGEMS        - Specifies what version of RubyGems to test
                          against. (e.g. USE_RUBYGEMS="1.8.12")
    UPTO_RUBY           - Specifies the cutoff version of Ruby so
                          that :setup won't try to downgrade RubyGems
			  on Ruby >= 2.0

Modified the .travis.yml file to include the environment variables to test
against.
  • Loading branch information
mgoggin committed Apr 17, 2013
1 parent 3a6d97f commit 04c2db3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
@@ -1,9 +1,12 @@
language: ruby
before_script:
- rake setup
- gem install rake -v "~> 0.9.2.2"
- gem install minitest -v "~> 3.2"
rvm:
- 1.8.7
- 1.9.3
- 2.0.0

env:
- USE_RUBYGEMS="1.8.25" UPTO_RUBY="2.0.0"
- USE_RUBYGEMS="2.0.3"
15 changes: 8 additions & 7 deletions rakefile.rb
Expand Up @@ -41,13 +41,14 @@
lib_dirs = ["lib", "test"].join(File::PATH_SEPARATOR)
test_files = FileList["test/**/test*.rb"].gsub("test/", "")

if ENV["TRAVIS"] && ENV["CI"] && RUBY_VERSION < "2.0.0"
%w(1.8.25 2.0.3).each do |version|
sh "gem update --system #{version}"
ruby "-I#{lib_dirs} -e \"ARGV.each { |f| require f }\" #{test_files}"
end
else
ruby "-I#{lib_dirs} -e \"ARGV.each { |f| require f }\" #{test_files}"
ruby "-I#{lib_dirs} -e \"ARGV.each { |f| require f }\" #{test_files}"
end

desc "Sets up the test environment"
task :setup do
if ENV["USE_RUBYGEMS"] && (!ENV["UPTO_RUBY"] || RUBY_VERSION < "#{ENV["UPTO_RUBY"]}")
sh "gem update -q --system #{ENV["USE_RUBYGEMS"]}"
puts "Using RubyGems #{`gem --version`}"
end
end

Expand Down

0 comments on commit 04c2db3

Please sign in to comment.