diff options
22 files changed, 50 insertions, 93 deletions
diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 9d3c9086c9..f6baa4a9e8 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -1,7 +1,4 @@ -require File.expand_path('../../../bundler', __FILE__) - -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 'action_mailer' @@ -17,7 +14,7 @@ ActionView::Template.register_template_handler :bak, lambda { |template| "Lame b FIXTURE_LOAD_PATH = File.expand_path('fixtures', File.dirname(__FILE__)) ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH -class MockSMTP +class MockSMTP def self.deliveries @@deliveries end diff --git a/actionmailer/test/log_subscriber_test.rb b/actionmailer/test/log_subscriber_test.rb index 57b4a6a7f0..edd7c84d29 100644 --- a/actionmailer/test/log_subscriber_test.rb +++ b/actionmailer/test/log_subscriber_test.rb @@ -1,6 +1,3 @@ -railties_path = File.expand_path('../../../railties/lib', __FILE__) -$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) - require "abstract_unit" require "rails/log_subscriber/test_helper" require "action_mailer/railties/log_subscriber" diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 7b41db3fea..8be212c8ab 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -1,10 +1,4 @@ -require File.expand_path('../../../bundler', __FILE__) - -lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) - -activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__) -$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path) +require File.expand_path('../../../load_paths', __FILE__) $:.unshift(File.dirname(__FILE__) + '/lib') $:.unshift(File.dirname(__FILE__) + '/fixtures/helpers') diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb index ee5fbdb0ae..d089830857 100644 --- a/actionpack/test/activerecord/controller_runtime_test.rb +++ b/actionpack/test/activerecord/controller_runtime_test.rb @@ -1,6 +1,3 @@ -railties_path = File.expand_path('../../../../railties/lib', __FILE__) -$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) - require 'active_record_unit' require 'active_record/railties/controller_runtime' require 'fixtures/project' @@ -15,7 +12,7 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase render :inline => "<%= Project.all %>" end end - + include Rails::LogSubscriber::TestHelper tests LogSubscriberController @@ -42,4 +39,4 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase assert_equal 2, @logger.logged(:info).size assert_match /\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1] end -end +end
\ No newline at end of file diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 5a3a2dd3ea..668d6ae5ea 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -1,6 +1,3 @@ -railties_path = File.expand_path('../../../../railties/lib', __FILE__) -$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) - require "abstract_unit" require "rails/log_subscriber/test_helper" require "action_controller/railties/log_subscriber" diff --git a/actionpack/test/template/log_subscriber_test.rb b/actionpack/test/template/log_subscriber_test.rb index f370810e81..2eb2484cf5 100644 --- a/actionpack/test/template/log_subscriber_test.rb +++ b/actionpack/test/template/log_subscriber_test.rb @@ -1,6 +1,3 @@ -railties_path = File.expand_path('../../../../railties/lib', __FILE__) -$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) - require "abstract_unit" require "rails/log_subscriber/test_helper" require "action_view/railties/log_subscriber" @@ -93,4 +90,4 @@ class AVLogSubscriberTest < ActiveSupport::TestCase assert_equal 1, @logger.logged(:info).size assert_match /Rendered collection/, @logger.logged(:info).last end -end +end
\ No newline at end of file diff --git a/activemodel/Rakefile b/activemodel/Rakefile index 556ea2ec0b..14c02f183f 100755 --- a/activemodel/Rakefile +++ b/activemodel/Rakefile @@ -13,7 +13,7 @@ require 'rake/testtask' task :default => :test Rake::TestTask.new do |t| - t.libs << "test" + t.libs << "#{dir}/test" t.test_files = Dir.glob("#{dir}/test/cases/**/*_test.rb").sort t.warning = true end diff --git a/activemodel/test/cases/helper.rb b/activemodel/test/cases/helper.rb index 8b1ab9e196..8bcbe54651 100644 --- a/activemodel/test/cases/helper.rb +++ b/activemodel/test/cases/helper.rb @@ -1,9 +1,4 @@ -require File.expand_path('../../../../bundler', __FILE__) - -lib = File.expand_path("#{File.dirname(__FILE__)}/../../lib") -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) - -puts $LOAD_PATH.inspect +require File.expand_path('../../../../load_paths', __FILE__) require 'config' require 'active_model' diff --git a/activemodel/test/cases/tests_database.rb b/activemodel/test/cases/tests_database.rb index 4a392f609f..8ca54d2678 100644 --- a/activemodel/test/cases/tests_database.rb +++ b/activemodel/test/cases/tests_database.rb @@ -1,8 +1,6 @@ require 'logger' -activerecord_path = File.expand_path('../../../../activerecord/lib', __FILE__) -$:.unshift(activerecord_path) if File.directory?(activerecord_path) && !$:.include?(activerecord_path) - +$:.unshift(File.dirname(__FILE__) + '/../../../activerecord/lib') require 'active_record' module ActiveModel diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index 99ff0a19a5..b79da4565d 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -21,6 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ + activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__) $:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path) diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 3254e7d800..9e8bfbbee8 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -1,7 +1,4 @@ -require File.expand_path('../../../../bundler', __FILE__) - -lib = File.expand_path("#{File.dirname(__FILE__)}/../../lib") -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../../load_paths', __FILE__) require 'config' diff --git a/activerecord/test/cases/log_subscriber_test.rb b/activerecord/test/cases/log_subscriber_test.rb index f854499435..f0197ddf77 100644 --- a/activerecord/test/cases/log_subscriber_test.rb +++ b/activerecord/test/cases/log_subscriber_test.rb @@ -1,6 +1,3 @@ -railties_path = File.expand_path('../../../../railties/lib', __FILE__) -$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) - require "cases/helper" require "models/developer" require "rails/log_subscriber/test_helper" @@ -42,4 +39,4 @@ class LogSubscriberTest < ActiveSupport::TestCase assert_match /CACHE/, @logger.logged(:debug).last assert_match /SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last end -end +end
\ No newline at end of file diff --git a/activeresource/test/abstract_unit.rb b/activeresource/test/abstract_unit.rb index 1c6f92cba4..1af535e811 100644 --- a/activeresource/test/abstract_unit.rb +++ b/activeresource/test/abstract_unit.rb @@ -1,7 +1,4 @@ -require File.expand_path('../../../bundler', __FILE__) - -lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../load_paths', __FILE__) require 'rubygems' require 'test/unit' @@ -9,6 +6,7 @@ require 'active_resource' require 'active_support' require 'active_support/test_case' +$:.unshift "#{File.dirname(__FILE__)}/../test" require 'setter_trap' require 'logger' diff --git a/activeresource/test/cases/log_subscriber_test.rb b/activeresource/test/cases/log_subscriber_test.rb index 45eb4da8a4..c25dd4ebc5 100644 --- a/activeresource/test/cases/log_subscriber_test.rb +++ b/activeresource/test/cases/log_subscriber_test.rb @@ -1,6 +1,3 @@ -railties_path = File.expand_path('../../../../railties/lib', __FILE__) -$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) - require "abstract_unit" require "fixtures/person" require "rails/log_subscriber/test_helper" @@ -32,4 +29,4 @@ class LogSubscriberTest < ActiveSupport::TestCase assert_equal "GET http://37s.sunrise.i:3000/people/1.xml", @logger.logged(:info)[0] assert_match /\-\-\> 200 200 106/, @logger.logged(:info)[1] end -end +end
\ No newline at end of file diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index c4ef102bf0..33be6f65bf 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -1,7 +1,4 @@ -require File.expand_path('../../../bundler', __FILE__) - -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/bundler.rb b/bundler.rb deleted file mode 100644 index dcc8ed61f1..0000000000 --- a/bundler.rb +++ /dev/null @@ -1,10 +0,0 @@ -begin - require File.expand_path('../.bundle/environment', __FILE__) -rescue LoadError - begin - require 'rubygems' - require 'bundler' - Bundler.setup - rescue LoadError - end -end diff --git a/load_paths.rb b/load_paths.rb new file mode 100644 index 0000000000..d5f2ca0734 --- /dev/null +++ b/load_paths.rb @@ -0,0 +1,21 @@ +begin + require File.expand_path('../.bundle/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 diff --git a/railties/Rakefile b/railties/Rakefile index d4b446bc24..f32a794544 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -1,4 +1,4 @@ -require File.expand_path('../../bundler', __FILE__) +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 2ac165fc49..aa66dbb9be 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -1,13 +1,8 @@ ORIG_ARGV = ARGV.dup -require File.expand_path("../../../bundler", __FILE__) +require File.expand_path("../../../load_paths", __FILE__) $:.unshift File.expand_path("../../builtin/rails_info", __FILE__) -lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) - -require 'edge_rails' - require 'stringio' require 'test/unit' require 'fileutils' diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 3e03a01ff3..acf752a448 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -140,7 +140,7 @@ module ApplicationTests require "#{app_path}/config/environment" end end - + test "filter_parameters should be able to set via config.filter_parameters" do add_to_config <<-RUBY config.filter_parameters += [ :foo, 'bar', lambda { |key, value| diff --git a/railties/test/edge_rails.rb b/railties/test/edge_rails.rb deleted file mode 100644 index bd8a674738..0000000000 --- a/railties/test/edge_rails.rb +++ /dev/null @@ -1,14 +0,0 @@ -require File.expand_path('../../../bundler', __FILE__) - -%w( - actionmailer - actionpack - activemodel - activerecord - activeresource - activesupport - railties -).each do |framework| - framework_path = File.expand_path("../../../#{framework}/lib", __FILE__) - $:.unshift(framework_path) if File.directory?(framework_path) && !$:.include?(framework_path) -end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index f3c1d64f7b..364dbd8e55 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -187,7 +187,7 @@ module TestHelpers end def boot_rails - require File.expand_path('../../edge_rails', __FILE__) + require File.expand_path('../../../../load_paths', __FILE__) end end end @@ -208,12 +208,18 @@ Module.new do end FileUtils.mkdir(tmp_path) - environment = File.expand_path('../../edge_rails', __FILE__) - require_environment = "-r #{environment}" + 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 + f.puts "Dir.chdir('#{File.dirname(environment)}') do" + f.puts " require '#{environment}'" + f.puts "end" + end f.puts "require 'rails/all'" end end |