Browse files

Fix test load paths for those not using bundler

  • Loading branch information...
1 parent 7cff54f commit eec2d301d4ce9df9c71c1a5aa63053eb970b6818 @josh josh committed Feb 15, 2010
View
7 actionmailer/test/abstract_unit.rb
@@ -1,4 +1,7 @@
-require File.expand_path('../../../load_paths', __FILE__)
+require File.expand_path('../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'test/unit'
require 'action_mailer'
@@ -14,7 +17,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
View
3 actionmailer/test/subscriber_test.rb
@@ -1,3 +1,6 @@
+railties_path = File.expand_path('../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require "abstract_unit"
require "rails/subscriber/test_helper"
require "action_mailer/railties/subscriber"
View
8 actionpack/test/abstract_unit.rb
@@ -1,4 +1,10 @@
-require File.expand_path('../../../load_paths', __FILE__)
+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)
$:.unshift(File.dirname(__FILE__) + '/lib')
$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
View
9 actionpack/test/activerecord/controller_runtime_test.rb
@@ -1,3 +1,6 @@
+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'
@@ -12,7 +15,7 @@ def show
render :inline => "<%= Project.all %>"
end
end
-
+
include Rails::Subscriber::TestHelper
tests SubscriberController
@@ -31,12 +34,12 @@ def teardown
def set_logger(logger)
ActionController::Base.logger = logger
end
-
+
def test_log_with_active_record
get :show
wait
assert_equal 2, @logger.logged(:info).size
assert_match /\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1]
end
-end
+end
View
3 actionpack/test/controller/subscriber_test.rb
@@ -1,3 +1,6 @@
+railties_path = File.expand_path('../../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require "abstract_unit"
require "rails/subscriber/test_helper"
require "action_controller/railties/subscriber"
View
5 actionpack/test/template/subscriber_test.rb
@@ -1,3 +1,6 @@
+railties_path = File.expand_path('../../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require "abstract_unit"
require "rails/subscriber/test_helper"
require "action_view/railties/subscriber"
@@ -90,4 +93,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
View
2 activemodel/Rakefile
@@ -13,7 +13,7 @@ require 'rake/testtask'
task :default => :test
Rake::TestTask.new do |t|
- t.libs << "#{dir}/test"
+ t.libs << "test"
t.test_files = Dir.glob("#{dir}/test/cases/**/*_test.rb").sort
t.warning = true
end
View
7 activemodel/test/cases/helper.rb
@@ -1,4 +1,9 @@
-require File.expand_path('../../../../load_paths', __FILE__)
+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 'config'
require 'active_model'
View
4 activemodel/test/cases/tests_database.rb
@@ -1,6 +1,8 @@
require 'logger'
-$:.unshift(File.dirname(__FILE__) + '/../../../activerecord/lib')
+activerecord_path = File.expand_path('../../../../activerecord/lib', __FILE__)
+$:.unshift(activerecord_path) if File.directory?(activerecord_path) && !$:.include?(activerecord_path)
+
require 'active_record'
module ActiveModel
View
1 activerecord/lib/active_record.rb
@@ -21,7 +21,6 @@
# 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)
View
5 activerecord/test/cases/helper.rb
@@ -1,4 +1,7 @@
-require File.expand_path('../../../../load_paths', __FILE__)
+require File.expand_path('../../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'config'
View
5 activerecord/test/cases/subscriber_test.rb
@@ -1,3 +1,6 @@
+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/subscriber/test_helper"
@@ -39,4 +42,4 @@ def test_cached_queries
assert_match /CACHE/, @logger.logged(:debug).last
assert_match /SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last
end
-end
+end
View
6 activeresource/test/abstract_unit.rb
@@ -1,12 +1,14 @@
-require File.expand_path('../../../load_paths', __FILE__)
+require File.expand_path('../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
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'
View
6 activeresource/test/cases/subscriber_test.rb
@@ -1,9 +1,13 @@
+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/subscriber/test_helper"
require "active_resource/railties/subscriber"
require "active_support/core_ext/hash/conversions"
+# TODO: This test should be part of Railties
class SubscriberTest < ActiveSupport::TestCase
include Rails::Subscriber::TestHelper
Rails::Subscriber.add(:active_resource, ActiveResource::Railties::Subscriber.new)
@@ -28,4 +32,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
View
5 activesupport/test/abstract_unit.rb
@@ -1,4 +1,7 @@
-require File.expand_path('../../../load_paths', __FILE__)
+require File.expand_path('../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'test/unit'
require 'mocha'
View
10 bundler.rb
@@ -0,0 +1,10 @@
+begin
+ require File.expand_path('../.bundle/environment', __FILE__)
+rescue LoadError
+ begin
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup
+ rescue LoadError
+ end
+end
View
21 load_paths.rb
@@ -1,21 +0,0 @@
-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
View
2 railties/Rakefile
@@ -1,4 +1,4 @@
-require File.expand_path('../../load_paths', __FILE__)
+require File.expand_path('../../bundler', __FILE__)
require 'rake'
require 'rake/testtask'
View
7 railties/test/abstract_unit.rb
@@ -1,8 +1,13 @@
ORIG_ARGV = ARGV.dup
-require File.expand_path("../../../load_paths", __FILE__)
+require File.expand_path("../../../bundler", __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'
View
2 railties/test/application/configuration_test.rb
@@ -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|
View
14 railties/test/edge_rails.rb
@@ -0,0 +1,14 @@
+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
View
14 railties/test/isolation/abstract_unit.rb
@@ -187,7 +187,7 @@ def use_frameworks(arr)
end
def boot_rails
- require File.expand_path('../../../../load_paths', __FILE__)
+ require File.expand_path('../../edge_rails', __FILE__)
end
end
end
@@ -208,18 +208,12 @@ class Test::Unit::TestCase
end
FileUtils.mkdir(tmp_path)
- environment = File.expand_path('../../../../load_paths', __FILE__)
- if File.exist?("#{environment}.rb")
- require_environment = "-r #{environment}"
- end
+ environment = File.expand_path('../../edge_rails', __FILE__)
+ require_environment = "-r #{environment}"
`#{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|
- if require_environment
- f.puts "Dir.chdir('#{File.dirname(environment)}') do"
- f.puts " require '#{environment}'"
- f.puts "end"
- end
+ f.puts "require '#{environment}'"
f.puts "require 'rails/all'"
end
end

0 comments on commit eec2d30

Please sign in to comment.