diff --git a/Gemfile b/Gemfile index 68f68aa22d80f..68e6487e2c0e1 100644 --- a/Gemfile +++ b/Gemfile @@ -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 @@ -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" @@ -34,5 +35,3 @@ if ENV['CI'] gem "test-unit", ">= 2.0.5" end end - -disable_system_gems diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index ce09bb5d61254..8fb941f9c96d7 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -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' diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 7b04638ccc246..867e50d5b9599 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -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') @@ -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 diff --git a/activemodel/test/cases/helper.rb b/activemodel/test/cases/helper.rb index 917bb720d0606..8bcbe546516cd 100644 --- a/activemodel/test/cases/helper.rb +++ b/activemodel/test/cases/helper.rb @@ -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' diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index fa76e2d57a652..9e8bfbbee8738 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -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' diff --git a/activeresource/test/abstract_unit.rb b/activeresource/test/abstract_unit.rb index 1e71d5d0dd355..2f43916521fba 100644 --- a/activeresource/test/abstract_unit.rb +++ b/activeresource/test/abstract_unit.rb @@ -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' diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index d91e0415c4773..33be6f65bfe80 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -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' diff --git a/load_paths.rb b/load_paths.rb new file mode 100644 index 0000000000000..55e2a530bd8f1 --- /dev/null +++ b/load_paths.rb @@ -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 \ No newline at end of file diff --git a/railties/Rakefile b/railties/Rakefile index b8f5e81b85045..ea0b8ef8fb982 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -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' diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 77ef82856a57a..aa66dbb9be217 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -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' diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 940585836c006..ff4ee6332bf4e 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -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 @@ -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