Skip to content
Browse files

replace Rake + ruby CI runner with one in bash

  • Loading branch information...
1 parent 0478099 commit 6e6cca414bb3ba524277859954072f84f2678799 @mislav committed
Showing with 45 additions and 66 deletions.
  1. +5 −2 .travis.yml
  2. +0 −1 Gemfile
  3. +0 −1 Gemfile.lock
  4. +0 −1 Gemfile.rails-edge
  5. +0 −1 Gemfile.rails-edge.lock
  6. +0 −1 Gemfile.rails3.0
  7. +0 −2 Gemfile.rails3.0.lock
  8. +0 −1 Gemfile.rails3.1
  9. +0 −1 Gemfile.rails3.1.lock
  10. +0 −25 Rakefile
  11. +21 −0 script/test_all
  12. +0 −29 spec/ci.rb
  13. +18 −0 spec/fake_rubygems.rb
  14. +1 −1 spec/spec_helper.rb
View
7 .travis.yml
@@ -1,6 +1,9 @@
-bundler_args: "--without development"
-script: spec/ci.rb
+bundler_args: "--standalone --binstubs --without development"
+script: script/test_all
services: mongodb
+before_script:
+ - mysql -e 'create database will_paginate;'
+ - psql -c 'create database will_paginate;' -U postgres
rvm:
- 1.8.7
- 1.9.2
View
1 Gemfile
@@ -5,7 +5,6 @@ rails_version = '~> 3.2.0'
gem 'activerecord', rails_version
gem 'actionpack', rails_version
-gem 'rake'
gem 'rspec', '~> 2.6.0'
gem 'mocha', '~> 0.9.8'
View
1 Gemfile.lock
@@ -117,7 +117,6 @@ DEPENDENCIES
mysql (~> 2.8.1)
mysql2 (>= 0.3.6)
pg (~> 0.11)
- rake
rspec (~> 2.6.0)
ruby-debug
sequel (~> 3.8)
View
1 Gemfile.rails-edge
@@ -8,7 +8,6 @@ gem 'actionpack', :github => 'rails/rails', :branch => 'master'
gem 'thread_safe'
-gem 'rake'
gem 'rspec', '~> 2.6.0'
gem 'mocha', '~> 0.9.8'
View
1 Gemfile.rails-edge.lock
@@ -102,7 +102,6 @@ DEPENDENCIES
mysql (~> 2.9)
mysql2 (>= 0.3.6)
pg (~> 0.11)
- rake
rspec (~> 2.6.0)
ruby-debug
sqlite3 (~> 1.3.3)
View
1 Gemfile.rails3.0
@@ -5,7 +5,6 @@ rails_version = '~> 3.0.0'
gem 'activerecord', rails_version
gem 'actionpack', rails_version
-gem 'rake'
gem 'rspec', '~> 2.6.0'
gem 'mocha', '~> 0.9.8'
View
2 Gemfile.rails3.0.lock
@@ -46,7 +46,6 @@ GEM
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
- rake (0.9.2)
rbx-require-relative (0.0.5)
rspec (2.6.0)
rspec-core (~> 2.6.0)
@@ -74,7 +73,6 @@ DEPENDENCIES
mocha (~> 0.9.8)
mysql (~> 2.8.1)
pg (~> 0.11)
- rake
rspec (~> 2.6.0)
ruby-debug
sqlite3 (~> 1.3.3)
View
1 Gemfile.rails3.1
@@ -5,7 +5,6 @@ rails_version = '~> 3.1.0'
gem 'activerecord', rails_version
gem 'actionpack', rails_version
-gem 'rake'
gem 'rspec', '~> 2.6.0'
gem 'mocha', '~> 0.9.8'
View
1 Gemfile.rails3.1.lock
@@ -88,7 +88,6 @@ DEPENDENCIES
mysql (~> 2.8.1)
mysql2 (>= 0.3.6)
pg (~> 0.11)
- rake
rspec (~> 2.6.0)
ruby-debug
sqlite3 (~> 1.3.3)
View
25 Rakefile
@@ -1,25 +0,0 @@
-begin
- require 'rspec/core/rake_task'
-rescue LoadError
- # no spec tasks
-else
- task :default => :spec
-
- desc 'Run ALL OF the specs'
- RSpec::Core::RakeTask.new(:spec) do |t|
- # t.ruby_opts = '-w'
- t.pattern = 'spec/finders/active_record_spec.rb' if ENV['DB'] and ENV['DB'] != 'sqlite3'
- end
-
- namespace :spec do
- desc "Run Rails specs"
- RSpec::Core::RakeTask.new(:rails) do |t|
- t.pattern = %w'spec/finders/active_record_spec.rb spec/view_helpers/action_view_spec.rb'
- end
- 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'
-end
View
21 script/test_all
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+status=0
+
+run_all(){
+ spec_files="spec"
+ [[ $DB != "sqlite3" ]] && spec_files="spec/finders/active_record_spec.rb"
+ set -x
+ rspec -r fake_rubygems $spec_files
+ set +x
+}
+
+export PATH="${PWD}/bin:$PATH"
+
+for db in sqlite3 mysql mysql2 postgres; do
+ if ! [[ $db = "mysql2" && $BUNDLE_GEMFILE =~ "rails3.0" ]]; then
+ printf "\e[1;33m[DB] ${db}\e[m\n"
+ DB=$db run_all || status=1
+ fi
+done
+
+exit $status
View
29 spec/ci.rb
@@ -1,29 +0,0 @@
-#!/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
View
18 spec/fake_rubygems.rb
@@ -0,0 +1,18 @@
+# Makes the test suite compatible with Bundler standalone mode (used in CI)
+# because Active Record uses `gem` for loading adapters.
+Kernel.module_eval do
+
+ remove_method :gem if 'method' == defined? gem
+
+ def gem(*args)
+ return if $VERBOSE.nil?
+ $stderr << "warning: gem(#{args.map {|o| o.inspect }.join(', ')}) ignored"
+ $stderr << "; called from:\n " << caller[0,5].join("\n ") if $DEBUG
+ $stderr << "\n"
+ end
+
+ private :gem
+
+end
+
+$" << "rubygems.rb"
View
2 spec/spec_helper.rb
@@ -1,5 +1,5 @@
require 'rspec'
-require File.expand_path('../view_helpers/view_example_group', __FILE__)
+require 'view_helpers/view_example_group'
begin
require 'ruby-debug'
rescue LoadError

0 comments on commit 6e6cca4

Please sign in to comment.
Something went wrong with that request. Please try again.