Skip to content

Commit

Permalink
Get rails tests running on bundler 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Lerche committed Feb 1, 2010
1 parent 9bd0422 commit 9f01dff
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 92 deletions.
19 changes: 9 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
gem "rake", ">= 0.8.7"
path File.expand_path('..', __FILE__)
source :gemcutter

gem "rails", "3.0.pre"

gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
gem "ruby-debug", ">= 0.10.3" if RUBY_VERSION < '1.9'

gem "rails", "3.0.pre", :path => "railties"
%w(activesupport activemodel actionpack actionmailer activerecord activeresource).each do |lib|
gem lib, '3.0.pre', :path => lib
if RUBY_VERSION < '1.9'
gem "ruby-debug", ">= 0.10.3"
end

# AR
gem "arel", ">= 0.2.0"
gem "sqlite3-ruby", ">= 1.2.5"

only :test do
group :test do
gem "pg", ">= 0.8.0"
gem "mysql", ">= 2.8.1"
end
Expand All @@ -21,8 +24,6 @@ gem "rack-test", "0.5.3"
gem "RedCloth", ">= 4.2.2"

if ENV['CI']
disable_system_gems

gem "nokogiri", ">= 1.4.0"
gem "memcache-client", ">= 1.7.6"

Expand All @@ -34,5 +35,3 @@ if ENV['CI']
gem "test-unit", ">= 2.0.5"
end
end

disable_system_gems
9 changes: 1 addition & 8 deletions actionmailer/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
begin
require File.expand_path('../../../vendor/gems/environment', __FILE__)
rescue LoadError
end

lib = File.expand_path('../../lib', __FILE__)
$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require File.expand_path('../../../load_paths', __FILE__)

require 'rubygems'
require 'test/unit'
require 'action_mailer'

Expand Down
11 changes: 1 addition & 10 deletions actionpack/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
begin
require File.expand_path('../../../vendor/gems/environment', __FILE__)
rescue LoadError
end

lib = File.expand_path('../../lib', __FILE__)
$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require File.expand_path('../../../load_paths', __FILE__)

$:.unshift(File.dirname(__FILE__) + '/lib')
$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
Expand All @@ -20,9 +14,6 @@
require 'action_dispatch'
require 'fixture_template'
require 'active_support/dependencies'

activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__)
$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path)
require 'active_model'

begin
Expand Down
8 changes: 1 addition & 7 deletions activemodel/test/cases/helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
begin
require File.expand_path('../../../../vendor/gems/environment', __FILE__)
rescue LoadError
end

lib = File.expand_path('../../../lib', __FILE__)
$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require File.expand_path('../../../../load_paths', __FILE__)

require 'config'
require 'active_model'
Expand Down
9 changes: 1 addition & 8 deletions activerecord/test/cases/helper.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
begin
require File.expand_path('../../../../vendor/gems/environment', __FILE__)
rescue LoadError
end

lib = File.expand_path('../../../lib', __FILE__)
$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require File.expand_path('../../../../load_paths', __FILE__)

require 'config'

require 'rubygems'
require 'test/unit'
require 'stringio'

Expand Down
8 changes: 1 addition & 7 deletions activeresource/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
begin
require File.expand_path('../../../vendor/gems/environment', __FILE__)
rescue LoadError
end

lib = File.expand_path('../../lib', __FILE__)
$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require File.expand_path('../../../load_paths', __FILE__)

require 'rubygems'
require 'test/unit'
Expand Down
10 changes: 1 addition & 9 deletions activesupport/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
ORIG_ARGV = ARGV.dup

begin
require File.expand_path('../../../vendor/gems/environment', __FILE__)
rescue LoadError
end

lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require File.expand_path('../../../load_paths', __FILE__)

require 'test/unit'
require 'mocha'
Expand Down
21 changes: 21 additions & 0 deletions load_paths.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
begin
require File.expand_path('../vendor/environment', __FILE__)
rescue LoadError
begin
require 'rubygems'
require 'bundler'
Bundler.setup
rescue LoadError
%w(
actionmailer
actionpack
activemodel
activerecord
activeresource
activesupport
railties
).each do |framework|
$:.unshift File.expand_path("../#{framework}/lib", __FILE__)
end
end
end
5 changes: 1 addition & 4 deletions railties/Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
begin
require File.expand_path('../../vendor/gems/environment', __FILE__)
rescue LoadError
end
require File.expand_path('../../load_paths', __FILE__)

require 'rake'
require 'rake/testtask'
Expand Down
12 changes: 2 additions & 10 deletions railties/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
ORIG_ARGV = ARGV.dup

root = File.expand_path('../../..', __FILE__)
begin
require "#{root}/vendor/gems/environment"
rescue LoadError
%w(activesupport activemodel activerecord actionpack actionmailer activeresource railties).each do |lib|
$:.unshift "#{root}/#{lib}/lib"
end
end

$:.unshift "#{root}/railties/builtin/rails_info"
require File.expand_path("../../../load_paths", __FILE__)
$:.unshift File.expand_path("../../builtin/rails_info", __FILE__)

require 'stringio'
require 'test/unit'
Expand Down
26 changes: 7 additions & 19 deletions railties/test/isolation/abstract_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,7 @@ def use_frameworks(arr)
end

def boot_rails
root = File.expand_path('../../../..', __FILE__)
begin
require "#{root}/vendor/gems/environment"
rescue LoadError
%w(
actionmailer/lib
actionpack/lib
activemodel/lib
activerecord/lib
activeresource/lib
activesupport/lib
railties/lib
railties
).reverse_each do |path|
$:.unshift "#{root}/#{path}"
end
end
require File.expand_path('../../../../load_paths', __FILE__)
end
end
end
Expand All @@ -220,14 +204,18 @@ class Test::Unit::TestCase
end
FileUtils.mkdir(tmp_path)

environment = File.expand_path('../../../../vendor/gems/environment', __FILE__)
environment = File.expand_path('../../../../load_paths', __FILE__)
if File.exist?("#{environment}.rb")
require_environment = "-r #{environment}"
end

`#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails #{tmp_path('app_template')}`
File.open("#{tmp_path}/app_template/config/boot.rb", 'w') do |f|
f.puts "require '#{environment}'" if require_environment
if require_environment
f.puts "Dir.chdir('#{File.dirname(environment)}') do"
f.puts " require '#{environment}'"
f.puts "end"
end
f.puts "require 'rails/all'"
end
end

0 comments on commit 9f01dff

Please sign in to comment.