Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Revert "Fix test load paths for those not using bundler"
Browse files Browse the repository at this point in the history
This reverts commit eec2d30.

This commit broke tests. You cannot have a file called "bundler" on the load path.
  • Loading branch information
Carlhuda committed Feb 24, 2010
1 parent 5e2bd08 commit 24ab566
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 93 deletions.
7 changes: 2 additions & 5 deletions actionmailer/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -17,7 +14,7 @@
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
Expand Down
3 changes: 0 additions & 3 deletions actionmailer/test/log_subscriber_test.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 1 addition & 7 deletions actionpack/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
7 changes: 2 additions & 5 deletions actionpack/test/activerecord/controller_runtime_test.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -15,7 +12,7 @@ def show
render :inline => "<%= Project.all %>"
end
end

include Rails::LogSubscriber::TestHelper
tests LogSubscriberController

Expand All @@ -42,4 +39,4 @@ def test_log_with_active_record
assert_equal 2, @logger.logged(:info).size
assert_match /\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1]
end
end
end
3 changes: 0 additions & 3 deletions actionpack/test/controller/log_subscriber_test.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 1 addition & 4 deletions actionpack/test/template/log_subscriber_test.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -93,4 +90,4 @@ def test_render_collection_template_without_path
assert_equal 1, @logger.logged(:info).size
assert_match /Rendered collection/, @logger.logged(:info).last
end
end
end
2 changes: 1 addition & 1 deletion activemodel/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions activemodel/test/cases/helper.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 1 addition & 3 deletions activemodel/test/cases/tests_database.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions activerecord/lib/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions activerecord/test/cases/helper.rb
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
5 changes: 1 addition & 4 deletions activerecord/test/cases/log_subscriber_test.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -42,4 +39,4 @@ def test_cached_queries
assert_match /CACHE/, @logger.logged(:debug).last
assert_match /SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last
end
end
end
6 changes: 2 additions & 4 deletions activeresource/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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'
require 'active_resource'
require 'active_support'
require 'active_support/test_case'

$:.unshift "#{File.dirname(__FILE__)}/../test"
require 'setter_trap'

require 'logger'
Expand Down
5 changes: 1 addition & 4 deletions activeresource/test/cases/log_subscriber_test.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -32,4 +29,4 @@ def test_request_notification
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
5 changes: 1 addition & 4 deletions activesupport/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
10 changes: 0 additions & 10 deletions bundler.rb

This file was deleted.

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('../.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
2 changes: 1 addition & 1 deletion railties/Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path('../../bundler', __FILE__)
require File.expand_path('../../load_paths', __FILE__)

require 'rake'
require 'rake/testtask'
Expand Down
7 changes: 1 addition & 6 deletions railties/test/abstract_unit.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion railties/test/application/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def teardown
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|
Expand Down
14 changes: 0 additions & 14 deletions railties/test/edge_rails.rb

This file was deleted.

14 changes: 10 additions & 4 deletions railties/test/isolation/abstract_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def use_frameworks(arr)
end

def boot_rails
require File.expand_path('../../edge_rails', __FILE__)
require File.expand_path('../../../../load_paths', __FILE__)
end
end
end
Expand All @@ -208,12 +208,18 @@ class Test::Unit::TestCase
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

0 comments on commit 24ab566

Please sign in to comment.