diff --git a/.travis.yml b/.travis.yml index 394e7b49b..487c06c63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,7 @@ +script: spec/ci.rb rvm: - 1.8.7 - 1.9.2 gemfile: - Gemfile - Gemfile.rails3.0 -env: - - DB=sqlite3 - - DB=mysql - - DB=mysql2 - - DB=postgres diff --git a/Gemfile.rails3.0 b/Gemfile.rails3.0 index 249646d9a..590b6b303 100644 --- a/Gemfile.rails3.0 +++ b/Gemfile.rails3.0 @@ -12,10 +12,7 @@ gem 'mocha', '~> 0.9.8' gem 'sqlite3', '~> 1.3.3' -group :mysql do - gem 'mysql', '~> 2.8.1' - gem 'mysql2', '>= 0.3.6' -end +gem 'mysql', '~> 2.8.1', :group => :mysql gem 'pg', '~> 0.11', :group => :pg group :debug do diff --git a/Gemfile.rails3.0.lock b/Gemfile.rails3.0.lock index 7a3db5bb7..b0f47ec4d 100644 --- a/Gemfile.rails3.0.lock +++ b/Gemfile.rails3.0.lock @@ -39,7 +39,6 @@ GEM ruby_core_source (>= 0.1.4) mocha (0.9.12) mysql (2.8.1) - mysql2 (0.3.6) pg (0.11.0) rack (1.2.3) rack-mount (0.6.14) @@ -83,7 +82,6 @@ DEPENDENCIES activeresource (~> 3.0.0) mocha (~> 0.9.8) mysql (~> 2.8.1) - mysql2 (>= 0.3.6) pg (~> 0.11) rake rspec (~> 2.6.0) diff --git a/Rakefile b/Rakefile index 749576bd4..374fd666a 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ begin rescue LoadError # no spec tasks else - task :default => [:create_database, :spec] + task :default => :spec desc 'Run ALL OF the specs' RSpec::Core::RakeTask.new(:spec) do |t| @@ -19,18 +19,6 @@ else end end -desc 'Create necessary databases' -task :create_database do |variable| - case ENV['DB'] - when 'mysql', 'mysql2' - `mysql -e 'create database will_paginate;'` - abort "failed to create mysql database" unless $?.success? - when 'postgres' - `psql -c 'create database will_paginate;' -U postgres` - abort "failed to create postgres database" unless $?.success? - end -end - desc 'Run specs against both Rails 3.1 and Rails 3.0' task :rails3 do |variable| system 'bundle exec rake spec && BUNDLE_GEMFILE=Gemfile.rails3.0 bundle exec rake spec:rails' diff --git a/spec/ci.rb b/spec/ci.rb new file mode 100755 index 000000000..8b9318787 --- /dev/null +++ b/spec/ci.rb @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +databases = %w[ sqlite3 mysql mysql2 postgres ] +databases.delete 'mysql2' if ENV['BUNDLE_GEMFILE'].to_s.include? 'rails3.0' + +def announce(name, msg) + puts "\n\e[1;33m[#{name}] #{msg}\e[m\n" +end + +def system(*args) + puts "$ #{args.join(' ')}" + super +end + +if ENV['TRAVIS'] + system "mysql -e 'create database will_paginate;' >/dev/null" + abort "failed to create mysql database" unless $?.success? + system "psql -c 'create database will_paginate;' -U postgres >/dev/null" + abort "failed to create postgres database" unless $?.success? +end + +failed = false + +for db in databases + announce "DB", db + ENV['DB'] = db + failed = true unless system %(rake) +end + +exit 1 if failed