From 6d214c953b74c40d6247dfd2d4526991a0f99f5c Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 13 Sep 2009 16:30:27 -0500 Subject: Merge abstract_controller/test_helper and new_base/test_helper since they are expected to run in the same testing sandbox --- actionpack/Rakefile | 31 +----- .../abstract_controller_test.rb | 2 +- .../test/abstract_controller/callbacks_test.rb | 4 +- actionpack/test/abstract_controller/helper_test.rb | 2 +- .../test/abstract_controller/layouts_test.rb | 2 +- actionpack/test/abstract_controller/test_helper.rb | 24 ----- actionpack/test/abstract_unit2.rb | 119 +++++++++++++++++++++ actionpack/test/active_record_unit.rb | 104 ++++++++++++++++++ actionpack/test/lib/active_record_unit.rb | 104 ------------------ actionpack/test/new_base/base_test.rb | 4 +- .../test/new_base/content_negotiation_test.rb | 4 +- actionpack/test/new_base/content_type_test.rb | 2 +- actionpack/test/new_base/etag_test.rb | 4 +- actionpack/test/new_base/metal_test.rb | 3 +- actionpack/test/new_base/middleware_test.rb | 2 +- actionpack/test/new_base/redirect_test.rb | 1 - actionpack/test/new_base/render_action_test.rb | 4 +- actionpack/test/new_base/render_file_test.rb | 4 +- .../test/new_base/render_implicit_action_test.rb | 4 +- actionpack/test/new_base/render_layout_test.rb | 4 +- actionpack/test/new_base/render_partial_test.rb | 4 +- actionpack/test/new_base/render_rjs_test.rb | 4 +- actionpack/test/new_base/render_template_test.rb | 4 +- actionpack/test/new_base/render_test.rb | 4 +- actionpack/test/new_base/render_text_test.rb | 4 +- actionpack/test/new_base/render_xml_test.rb | 4 +- actionpack/test/new_base/test_helper.rb | 113 ------------------- actionpack/test/runner | 8 -- 28 files changed, 261 insertions(+), 312 deletions(-) delete mode 100644 actionpack/test/abstract_controller/test_helper.rb create mode 100644 actionpack/test/abstract_unit2.rb create mode 100644 actionpack/test/active_record_unit.rb delete mode 100644 actionpack/test/lib/active_record_unit.rb delete mode 100644 actionpack/test/new_base/redirect_test.rb delete mode 100644 actionpack/test/new_base/test_helper.rb delete mode 100755 actionpack/test/runner diff --git a/actionpack/Rakefile b/actionpack/Rakefile index b923414cef..0d8362ad0b 100644 --- a/actionpack/Rakefile +++ b/actionpack/Rakefile @@ -34,11 +34,8 @@ end desc "Run all unit tests" task :test => [:test_action_pack, :test_active_record_integration, :test_new_base] -test_lib_dirs = ENV["NEW"] ? ["test/new_base"] : [] -test_lib_dirs.push "test", "test/lib" -# test_lib_dirs = [ENV["NEW"] ? "test/new_base" : "test", "test/lib"] Rake::TestTask.new(:test_action_pack) do |t| - t.libs.concat test_lib_dirs + t.libs << 'test' # make sure we include the tests in alphabetical order as on some systems # this will not happen automatically and the tests (as a whole) will error @@ -51,44 +48,24 @@ end task :isolated_test do ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) Dir.glob("test/{controller,dispatch,template}/**/*_test.rb").all? do |file| - system(ruby, "-Ilib:#{test_lib_dirs * ':'}", file) + system(ruby, "-Itest", file) end or raise "Failures" end desc 'ActiveRecord Integration Tests' Rake::TestTask.new(:test_active_record_integration) do |t| - t.libs.concat test_lib_dirs + t.libs << 'test' t.test_files = Dir.glob("test/activerecord/*_test.rb") t.verbose = true end desc 'New Controller Tests' Rake::TestTask.new(:test_new_base) do |t| - t.libs << "test/new_base" << "test/lib" + t.libs << 'test' t.test_files = Dir.glob("test/{abstract_controller,new_base}/*_test.rb") t.verbose = true end -desc 'Old Controller Tests on New Base' -Rake::TestTask.new(:test_new_base_on_old_tests) do |t| - t.libs << "test/new_base" << "test/lib" - - t.verbose = true - # ==== Not ported - # * filters - - t.test_files = Dir.glob( "test/{dispatch,template}/**/*_test.rb" ).sort + %w( - action_pack_assertions addresses_render assert_select - base benchmark caching capture content_type cookie dispatcher - filter_params flash helper http_basic_authentication - http_digest_authentication integration layout logging mime_responds - record_identifier redirect render render_js render_json - render_other render_xml request_forgery_protection rescue - resources routing selector send_file test url_rewriter - verification view_paths webservice - ).map { |name| "test/controller/#{name}_test.rb" } -end - # Genereate the RDoc documentation Rake::RDocTask.new { |rdoc| diff --git a/actionpack/test/abstract_controller/abstract_controller_test.rb b/actionpack/test/abstract_controller/abstract_controller_test.rb index 3b4046a424..0e6cfba5b5 100644 --- a/actionpack/test/abstract_controller/abstract_controller_test.rb +++ b/actionpack/test/abstract_controller/abstract_controller_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module AbstractController module Testing diff --git a/actionpack/test/abstract_controller/callbacks_test.rb b/actionpack/test/abstract_controller/callbacks_test.rb index 8f62adce8c..98656c0c70 100644 --- a/actionpack/test/abstract_controller/callbacks_test.rb +++ b/actionpack/test/abstract_controller/callbacks_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module AbstractController module Testing @@ -235,4 +235,4 @@ module AbstractController end end -end \ No newline at end of file +end diff --git a/actionpack/test/abstract_controller/helper_test.rb b/actionpack/test/abstract_controller/helper_test.rb index 34a10cecc9..4c013137f9 100644 --- a/actionpack/test/abstract_controller/helper_test.rb +++ b/actionpack/test/abstract_controller/helper_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module AbstractController module Testing diff --git a/actionpack/test/abstract_controller/layouts_test.rb b/actionpack/test/abstract_controller/layouts_test.rb index 995aac7fad..bee3b5c556 100644 --- a/actionpack/test/abstract_controller/layouts_test.rb +++ b/actionpack/test/abstract_controller/layouts_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' require 'active_support/core_ext/class/removal' module AbstractControllerTests diff --git a/actionpack/test/abstract_controller/test_helper.rb b/actionpack/test/abstract_controller/test_helper.rb deleted file mode 100644 index 18e4d3c0e5..0000000000 --- a/actionpack/test/abstract_controller/test_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -$:.unshift(File.dirname(__FILE__) + '/../../lib') -$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib') -$:.unshift(File.dirname(__FILE__) + '/../lib') - -bundler = File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'gems', 'environment') -require bundler if File.exist?("#{bundler}.rb") - -require 'rubygems' -require 'test/unit' -require 'active_support' -require 'active_support/test_case' -require 'abstract_controller' -require 'action_view' -require 'action_view/base' -require 'action_dispatch' -require 'fixture_template' - -begin - require 'ruby-debug' - Debugger.settings[:autoeval] = true - Debugger.start -rescue LoadError - # Debugging disabled. `gem install ruby-debug` to enable. -end diff --git a/actionpack/test/abstract_unit2.rb b/actionpack/test/abstract_unit2.rb new file mode 100644 index 0000000000..5bda38243c --- /dev/null +++ b/actionpack/test/abstract_unit2.rb @@ -0,0 +1,119 @@ +# TODO: Unify with abstract_unit + +$:.unshift(File.dirname(__FILE__) + '/../lib') +$:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib') +$:.unshift(File.dirname(__FILE__) + '/../lib') +$:.unshift(File.dirname(__FILE__) + '/lib') + +bundler = File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'gems', 'environment') +require bundler if File.exist?("#{bundler}.rb") + +require 'test/unit' +require 'active_support' +require 'active_support/test_case' +require 'abstract_controller' +require 'action_view' +require 'action_view/base' +require 'action_dispatch' +require 'fixture_template' + +begin + require 'ruby-debug' + Debugger.settings[:autoeval] = true + Debugger.start +rescue LoadError + # Debugging disabled. `gem install ruby-debug` to enable. +end + +require 'action_controller' +require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late + +require 'action_controller/testing/process' +require 'action_controller/testing/integration' + +module Rails + def self.env + x = Object.new + def x.test?() true end + x + end +end + +# Temporary base class +class Rack::TestCase < ActionController::IntegrationTest + setup do + ActionController::Base.session_options[:key] = "abc" + ActionController::Base.session_options[:secret] = ("*" * 30) + end + + def app + @app ||= ActionController::Dispatcher.new + end + + def self.testing(klass = nil) + if klass + @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '') + else + @testing + end + end + + def get(thing, *args) + if thing.is_a?(Symbol) + super("#{self.class.testing}/#{thing}", *args) + else + super + end + end + + def assert_body(body) + assert_equal body, Array.wrap(response.body).join + end + + def assert_status(code) + assert_equal code, response.status + end + + def assert_response(body, status = 200, headers = {}) + assert_body body + assert_status status + headers.each do |header, value| + assert_header header, value + end + end + + def assert_content_type(type) + assert_equal type, response.headers["Content-Type"] + end + + def assert_header(name, value) + assert_equal value, response.headers[name] + end +end + +class ::ApplicationController < ActionController::Base +end + +module ActionController + class << Routing + def possible_controllers + @@possible_controllers ||= [] + end + end + + class Base + def self.inherited(klass) + name = klass.name.underscore.sub(/_controller$/, '') + ActionController::Routing.possible_controllers << name unless name.blank? + super + end + end +end + +class SimpleRouteCase < Rack::TestCase + setup do + ActionController::Routing::Routes.draw do |map| + map.connect ':controller/:action/:id' + end + end +end diff --git a/actionpack/test/active_record_unit.rb b/actionpack/test/active_record_unit.rb new file mode 100644 index 0000000000..9e0c66055d --- /dev/null +++ b/actionpack/test/active_record_unit.rb @@ -0,0 +1,104 @@ +require 'abstract_unit' + +# Define the essentials +class ActiveRecordTestConnector + cattr_accessor :able_to_connect + cattr_accessor :connected + + # Set our defaults + self.connected = false + self.able_to_connect = true +end + +# Try to grab AR +if defined?(ActiveRecord) && defined?(Fixtures) + $stderr.puts 'Active Record is already loaded, running tests' +else + $stderr.print 'Attempting to load Active Record... ' + begin + PATH_TO_AR = "#{File.dirname(__FILE__)}/../../activerecord/lib" + raise LoadError, "#{PATH_TO_AR} doesn't exist" unless File.directory?(PATH_TO_AR) + $LOAD_PATH.unshift PATH_TO_AR + require 'active_record' + require 'active_record/fixtures' + $stderr.puts 'success' + rescue LoadError => e + $stderr.print "failed. Skipping Active Record assertion tests: #{e}" + ActiveRecordTestConnector.able_to_connect = false + end +end +$stderr.flush + + +# Define the rest of the connector +class ActiveRecordTestConnector + class << self + def setup + unless self.connected || !self.able_to_connect + setup_connection + load_schema + require_fixture_models + self.connected = true + end + rescue Exception => e # errors from ActiveRecord setup + $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}" + #$stderr.puts " #{e.backtrace.join("\n ")}\n" + self.able_to_connect = false + end + + private + def setup_connection + if Object.const_defined?(:ActiveRecord) + defaults = { :database => ':memory:' } + begin + adapter = defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' + options = defaults.merge :adapter => adapter, :timeout => 500 + ActiveRecord::Base.establish_connection(options) + ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options } + ActiveRecord::Base.connection + rescue Exception # errors from establishing a connection + $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.' + options = defaults.merge :adapter => 'sqlite' + ActiveRecord::Base.establish_connection(options) + ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options } + ActiveRecord::Base.connection + end + + Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE) + else + raise "Can't setup connection since ActiveRecord isn't loaded." + end + end + + # Load actionpack sqlite tables + def load_schema + File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql| + ActiveRecord::Base.connection.execute(sql) unless sql.blank? + end + end + + def require_fixture_models + Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f} + end + end +end + +class ActiveRecordTestCase < ActionController::TestCase + include ActiveRecord::TestFixtures + + # Set our fixture path + if ActiveRecordTestConnector.able_to_connect + self.fixture_path = [FIXTURE_LOAD_PATH] + self.use_transactional_fixtures = false + end + + def self.fixtures(*args) + super if ActiveRecordTestConnector.connected + end + + def run(*args) + super if ActiveRecordTestConnector.connected + end +end + +ActiveRecordTestConnector.setup diff --git a/actionpack/test/lib/active_record_unit.rb b/actionpack/test/lib/active_record_unit.rb deleted file mode 100644 index 1ba308e9d7..0000000000 --- a/actionpack/test/lib/active_record_unit.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'abstract_unit' - -# Define the essentials -class ActiveRecordTestConnector - cattr_accessor :able_to_connect - cattr_accessor :connected - - # Set our defaults - self.connected = false - self.able_to_connect = true -end - -# Try to grab AR -if defined?(ActiveRecord) && defined?(Fixtures) - $stderr.puts 'Active Record is already loaded, running tests' -else - $stderr.print 'Attempting to load Active Record... ' - begin - PATH_TO_AR = "#{File.dirname(__FILE__)}/../../../activerecord/lib" - raise LoadError, "#{PATH_TO_AR} doesn't exist" unless File.directory?(PATH_TO_AR) - $LOAD_PATH.unshift PATH_TO_AR - require 'active_record' - require 'active_record/fixtures' - $stderr.puts 'success' - rescue LoadError => e - $stderr.print "failed. Skipping Active Record assertion tests: #{e}" - ActiveRecordTestConnector.able_to_connect = false - end -end -$stderr.flush - - -# Define the rest of the connector -class ActiveRecordTestConnector - class << self - def setup - unless self.connected || !self.able_to_connect - setup_connection - load_schema - require_fixture_models - self.connected = true - end - rescue Exception => e # errors from ActiveRecord setup - $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}" - #$stderr.puts " #{e.backtrace.join("\n ")}\n" - self.able_to_connect = false - end - - private - def setup_connection - if Object.const_defined?(:ActiveRecord) - defaults = { :database => ':memory:' } - begin - adapter = defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' - options = defaults.merge :adapter => adapter, :timeout => 500 - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options } - ActiveRecord::Base.connection - rescue Exception # errors from establishing a connection - $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.' - options = defaults.merge :adapter => 'sqlite' - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options } - ActiveRecord::Base.connection - end - - Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE) - else - raise "Can't setup connection since ActiveRecord isn't loaded." - end - end - - # Load actionpack sqlite tables - def load_schema - File.read(File.dirname(__FILE__) + "/../fixtures/db_definitions/sqlite.sql").split(';').each do |sql| - ActiveRecord::Base.connection.execute(sql) unless sql.blank? - end - end - - def require_fixture_models - Dir.glob(File.dirname(__FILE__) + "/../fixtures/*.rb").each {|f| require f} - end - end -end - -class ActiveRecordTestCase < ActionController::TestCase - include ActiveRecord::TestFixtures - - # Set our fixture path - if ActiveRecordTestConnector.able_to_connect - self.fixture_path = [FIXTURE_LOAD_PATH] - self.use_transactional_fixtures = false - end - - def self.fixtures(*args) - super if ActiveRecordTestConnector.connected - end - - def run(*args) - super if ActiveRecordTestConnector.connected - end -end - -ActiveRecordTestConnector.setup diff --git a/actionpack/test/new_base/base_test.rb b/actionpack/test/new_base/base_test.rb index 1b2e917ced..3a559c9cb6 100644 --- a/actionpack/test/new_base/base_test.rb +++ b/actionpack/test/new_base/base_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' # Tests the controller dispatching happy path module Dispatching @@ -65,4 +65,4 @@ module Dispatching assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/content_negotiation_test.rb b/actionpack/test/new_base/content_negotiation_test.rb index d2f732738d..a2f9df597f 100644 --- a/actionpack/test/new_base/content_negotiation_test.rb +++ b/actionpack/test/new_base/content_negotiation_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module ContentNegotiation @@ -15,4 +15,4 @@ module ContentNegotiation assert_body "Hello world */*!" end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/content_type_test.rb b/actionpack/test/new_base/content_type_test.rb index ceee508224..7e95c715a0 100644 --- a/actionpack/test/new_base/content_type_test.rb +++ b/actionpack/test/new_base/content_type_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module ContentType class BaseController < ActionController::Base diff --git a/actionpack/test/new_base/etag_test.rb b/actionpack/test/new_base/etag_test.rb index 3a69e7dac4..64ae10b7a7 100644 --- a/actionpack/test/new_base/etag_test.rb +++ b/actionpack/test/new_base/etag_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module Etags class BasicController < ActionController::Base @@ -43,4 +43,4 @@ module Etags %("#{Digest::MD5.hexdigest(text)}") end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/metal_test.rb b/actionpack/test/new_base/metal_test.rb index 2b7720863a..613d03446c 100644 --- a/actionpack/test/new_base/metal_test.rb +++ b/actionpack/test/new_base/metal_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module MetalTest class MetalMiddleware < ActionController::Middleware @@ -41,4 +41,3 @@ module MetalTest end end end - diff --git a/actionpack/test/new_base/middleware_test.rb b/actionpack/test/new_base/middleware_test.rb index 15aef270e2..ecca7e51eb 100644 --- a/actionpack/test/new_base/middleware_test.rb +++ b/actionpack/test/new_base/middleware_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module MiddlewareTest class MyMiddleware diff --git a/actionpack/test/new_base/redirect_test.rb b/actionpack/test/new_base/redirect_test.rb deleted file mode 100644 index e591ebd05f..0000000000 --- a/actionpack/test/new_base/redirect_test.rb +++ /dev/null @@ -1 +0,0 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") \ No newline at end of file diff --git a/actionpack/test/new_base/render_action_test.rb b/actionpack/test/new_base/render_action_test.rb index dfa7cc2141..72a16e3b67 100644 --- a/actionpack/test/new_base/render_action_test.rb +++ b/actionpack/test/new_base/render_action_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module RenderAction # This has no layout and it works @@ -317,4 +317,4 @@ module RenderActionWithBothLayouts assert_status 200 end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_file_test.rb b/actionpack/test/new_base/render_file_test.rb index 8d7f49dbc2..7067baca18 100644 --- a/actionpack/test/new_base/render_file_test.rb +++ b/actionpack/test/new_base/render_file_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module RenderFile @@ -107,4 +107,4 @@ module RenderFile end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_implicit_action_test.rb b/actionpack/test/new_base/render_implicit_action_test.rb index fd96e1955f..03b9ff6eeb 100644 --- a/actionpack/test/new_base/render_implicit_action_test.rb +++ b/actionpack/test/new_base/render_implicit_action_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module RenderImplicitAction class SimpleController < ::ApplicationController @@ -25,4 +25,4 @@ module RenderImplicitAction assert_status 200 end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_layout_test.rb b/actionpack/test/new_base/render_layout_test.rb index 933eef58e7..0dfbae4e9d 100644 --- a/actionpack/test/new_base/render_layout_test.rb +++ b/actionpack/test/new_base/render_layout_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module ControllerLayouts class ImplicitController < ::ApplicationController @@ -98,4 +98,4 @@ module ControllerLayouts end end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_partial_test.rb b/actionpack/test/new_base/render_partial_test.rb index bbb98a0c01..ff775dbfd7 100644 --- a/actionpack/test/new_base/render_partial_test.rb +++ b/actionpack/test/new_base/render_partial_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module RenderPartial @@ -24,4 +24,4 @@ module RenderPartial end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_rjs_test.rb b/actionpack/test/new_base/render_rjs_test.rb index 3d3e516905..eecc275b1e 100644 --- a/actionpack/test/new_base/render_rjs_test.rb +++ b/actionpack/test/new_base/render_rjs_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module RenderRjs @@ -42,4 +42,4 @@ module RenderRjs end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_template_test.rb b/actionpack/test/new_base/render_template_test.rb index 967cbd07b0..5637565dac 100644 --- a/actionpack/test/new_base/render_template_test.rb +++ b/actionpack/test/new_base/render_template_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module RenderTemplate class WithoutLayoutController < ActionController::Base @@ -167,4 +167,4 @@ module RenderTemplate end end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_test.rb b/actionpack/test/new_base/render_test.rb index 5783b4766a..94820f1c9c 100644 --- a/actionpack/test/new_base/render_test.rb +++ b/actionpack/test/new_base/render_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module Render class BlankRenderController < ActionController::Base @@ -82,4 +82,4 @@ module Render assert_body "Controller Name: blank_render" end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_text_test.rb b/actionpack/test/new_base/render_text_test.rb index 84f77432c9..23660ed101 100644 --- a/actionpack/test/new_base/render_text_test.rb +++ b/actionpack/test/new_base/render_text_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module RenderText class SimpleController < ActionController::Base @@ -134,4 +134,4 @@ module RenderText assert_status 200 end end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/render_xml_test.rb b/actionpack/test/new_base/render_xml_test.rb index a3890ddfb2..86a7d9c8a5 100644 --- a/actionpack/test/new_base/render_xml_test.rb +++ b/actionpack/test/new_base/render_xml_test.rb @@ -1,4 +1,4 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") +require 'abstract_unit2' module RenderXml @@ -8,4 +8,4 @@ module RenderXml "render_xml/basic/with_render_erb" => "Hello world!" )] end -end \ No newline at end of file +end diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb deleted file mode 100644 index 33ea519e77..0000000000 --- a/actionpack/test/new_base/test_helper.rb +++ /dev/null @@ -1,113 +0,0 @@ -$:.unshift(File.dirname(__FILE__) + '/../../lib') -$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib') -$:.unshift(File.dirname(__FILE__) + '/../lib') - -bundler = File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'gems', 'environment') -require bundler if File.exist?("#{bundler}.rb") - -require 'test/unit' -require 'active_support' -require 'active_support/test_case' -require 'action_view' -require 'fixture_template' - -begin - require 'ruby-debug' - Debugger.settings[:autoeval] = true - Debugger.start -rescue LoadError - # Debugging disabled. `gem install ruby-debug` to enable. -end - -require 'action_controller' -require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late - -require 'action_controller/testing/process' -require 'action_controller/testing/integration' - -module Rails - def self.env - x = Object.new - def x.test?() true end - x - end -end - -# Temporary base class -class Rack::TestCase < ActionController::IntegrationTest - setup do - ActionController::Base.session_options[:key] = "abc" - ActionController::Base.session_options[:secret] = ("*" * 30) - end - - def app - @app ||= ActionController::Dispatcher.new - end - - def self.testing(klass = nil) - if klass - @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '') - else - @testing - end - end - - def get(thing, *args) - if thing.is_a?(Symbol) - super("#{self.class.testing}/#{thing}", *args) - else - super - end - end - - def assert_body(body) - assert_equal body, Array.wrap(response.body).join - end - - def assert_status(code) - assert_equal code, response.status - end - - def assert_response(body, status = 200, headers = {}) - assert_body body - assert_status status - headers.each do |header, value| - assert_header header, value - end - end - - def assert_content_type(type) - assert_equal type, response.headers["Content-Type"] - end - - def assert_header(name, value) - assert_equal value, response.headers[name] - end -end - -class ::ApplicationController < ActionController::Base -end - -module ActionController - class << Routing - def possible_controllers - @@possible_controllers ||= [] - end - end - - class Base - def self.inherited(klass) - name = klass.name.underscore.sub(/_controller$/, '') - ActionController::Routing.possible_controllers << name unless name.blank? - super - end - end -end - -class SimpleRouteCase < Rack::TestCase - setup do - ActionController::Routing::Routes.draw do |map| - map.connect ':controller/:action/:id' - end - end -end diff --git a/actionpack/test/runner b/actionpack/test/runner deleted file mode 100755 index c2bbe63c75..0000000000 --- a/actionpack/test/runner +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby - - -ARGV.each do |arg| - Dir["#{Dir.pwd}/#{arg}/**/*_test.rb"].each do |file| - require file - end -end \ No newline at end of file -- cgit v1.2.3