From f05b1e5eb1829be47bf9581ca6666229e01d597c Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 19 Sep 2009 12:10:41 -0500 Subject: All on one abstract_unit --- actionpack/test/abstract_unit.rb | 76 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'actionpack/test/abstract_unit.rb') diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 78f326e341..1aa4dcb741 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -16,15 +16,17 @@ ENV['new_base'] = "true" require 'test/unit' require 'active_support' require 'active_support/test_case' +require 'abstract_controller' require 'action_controller' +require 'action_view' +require 'action_view/base' +require 'action_dispatch' +require 'active_model' require 'fixture_template' require 'action_controller/testing/process' -require 'action_view/test_case' require 'action_controller/testing/integration' +require 'action_view/test_case' require 'active_support/dependencies' -require 'active_model' - -$tags[:new_base] = true begin require 'ruby-debug' @@ -34,6 +36,8 @@ rescue LoadError # Debugging disabled. `gem install ruby-debug` to enable. end +require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late + ActiveSupport::Dependencies.hook! # Show backtraces for deprecated behavior for quicker cleanup. @@ -56,6 +60,61 @@ module ActionView 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 Base.session = { :key => '_testing_session', @@ -132,3 +191,12 @@ module ActionController end end end + + +class SimpleRouteCase < Rack::TestCase + setup do + ActionController::Routing::Routes.draw do |map| + map.connect ':controller/:action/:id' + end + end +end -- cgit v1.2.3