diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-05-29 16:06:21 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-05-29 16:06:21 -0500 |
commit | 69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3 (patch) | |
tree | 044c2131cc87d21ee54027511aae2b7f2d2ae26a /actionpack/test/new_base/test_helper.rb | |
parent | 5f3f100ce2d689480da85abc88e5e940cf90189e (diff) | |
parent | 5ec2c7dc29b36d85b2658465b8a979deb0529d7e (diff) | |
download | rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.tar.gz rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.tar.bz2 rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.zip |
Merge branch 'master' into active_model
Conflicts:
activemodel/lib/active_model/core.rb
activemodel/test/cases/state_machine/event_test.rb
activemodel/test/cases/state_machine/state_transition_test.rb
activerecord/lib/active_record/validations.rb
activerecord/test/cases/validations/i18n_validation_test.rb
activeresource/lib/active_resource.rb
activeresource/test/abstract_unit.rb
Diffstat (limited to 'actionpack/test/new_base/test_helper.rb')
-rw-r--r-- | actionpack/test/new_base/test_helper.rb | 126 |
1 files changed, 46 insertions, 80 deletions
diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb index d29449ddc1..d92029df7f 100644 --- a/actionpack/test/new_base/test_helper.rb +++ b/actionpack/test/new_base/test_helper.rb @@ -5,8 +5,7 @@ $:.unshift(File.dirname(__FILE__) + '/../lib') require 'test/unit' require 'active_support' require 'active_support/test_case' -require 'action_controller' -require 'action_view/base' +require 'action_view' require 'fixture_template' begin @@ -21,118 +20,85 @@ require 'action_controller/abstract' require 'action_controller/new_base' require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late -require 'rubygems' -require 'rack/test' - -module ActionController - class Base2 < AbstractBase - use AbstractController::Callbacks - use AbstractController::Helpers - use AbstractController::Logger - - use ActionController::HideActions - use ActionController::UrlFor - use ActionController::Renderer - use ActionController::Layouts - - def self.inherited(klass) - ::ActionController::Base2.subclasses << klass.to_s - super - end - - def self.subclasses - @subclasses ||= [] - end - - def self.app_loaded! - @subclasses.each do |subclass| - subclass.constantize._write_layout_method - end - end - - # append_view_path File.join(File.dirname(__FILE__), '..', 'fixtures') - - CORE_METHODS = self.public_instance_methods +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 < ActiveSupport::TestCase - include Rack::Test::Methods - +class Rack::TestCase < ActionController::IntegrationTest setup do ActionController::Base.session_options[:key] = "abc" ActionController::Base.session_options[:secret] = ("*" * 30) - - controllers = ActionController::Base2.subclasses.map do |k| + + controllers = ActionController::Base.subclasses.map do |k| k.underscore.sub(/_controller$/, '') end - + ActionController::Routing.use_controllers!(controllers) - + # Move into a bootloader - AbstractController::Base.subclasses.each do |klass| + ActionController::Base.subclasses.each do |klass| klass = klass.constantize next unless klass < AbstractController::Layouts klass.class_eval do _write_layout_method end - end + end end - + def app @app ||= ActionController::Dispatcher.new end - - def self.get(url) - setup do |test| - test.get url + + def self.testing(klass = nil) + if klass + @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '') + else + @testing end end - - def assert_body(body) - assert_equal [body], last_response.body - end - - def self.assert_body(body) - test "body is set to '#{body}'" do - assert_body body + + 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, last_response.status + assert_equal code, response.status end - - def self.assert_status(code) - test "status code is set to #{code}" do - assert_status code + + 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, last_response.headers["Content-Type"] - end - - def self.assert_content_type(type) - test "content type is set to #{type}" do - assert_content_type(type) - end + assert_equal type, response.headers["Content-Type"] end - + def assert_header(name, value) - assert_equal value, last_response.headers[name] - end - - def self.assert_header(name, value) - test "'#{name}' header is set to #{value.inspect}" do - assert_header(name, value) - end + assert_equal value, response.headers[name] end - end -class ::ApplicationController < ActionController::Base2 +class ::ApplicationController < ActionController::Base end class SimpleRouteCase < Rack::TestCase |