aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract_unit.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-09-19 12:10:41 -0500
committerJoshua Peek <josh@joshpeek.com>2009-09-19 12:10:41 -0500
commitf05b1e5eb1829be47bf9581ca6666229e01d597c (patch)
tree4931a243be128a1f0129e37a9d50f6f0d1ff54f5 /actionpack/test/abstract_unit.rb
parenta6f19a155a0c9accb31ae12a24ff9145cce271b0 (diff)
downloadrails-f05b1e5eb1829be47bf9581ca6666229e01d597c.tar.gz
rails-f05b1e5eb1829be47bf9581ca6666229e01d597c.tar.bz2
rails-f05b1e5eb1829be47bf9581ca6666229e01d597c.zip
All on one abstract_unit
Diffstat (limited to 'actionpack/test/abstract_unit.rb')
-rw-r--r--actionpack/test/abstract_unit.rb76
1 files changed, 72 insertions, 4 deletions
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