aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract_unit2.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-09-13 16:30:27 -0500
committerJoshua Peek <josh@joshpeek.com>2009-09-13 16:30:27 -0500
commit6d214c953b74c40d6247dfd2d4526991a0f99f5c (patch)
tree83349dfa5e523a3afa4a6a1f61e6f3a848412f75 /actionpack/test/abstract_unit2.rb
parent199a423f42c58f3904d75d7a2ab08496bba907c4 (diff)
downloadrails-6d214c953b74c40d6247dfd2d4526991a0f99f5c.tar.gz
rails-6d214c953b74c40d6247dfd2d4526991a0f99f5c.tar.bz2
rails-6d214c953b74c40d6247dfd2d4526991a0f99f5c.zip
Merge abstract_controller/test_helper and new_base/test_helper since they are expected to run in the same testing sandbox
Diffstat (limited to 'actionpack/test/abstract_unit2.rb')
-rw-r--r--actionpack/test/abstract_unit2.rb119
1 files changed, 119 insertions, 0 deletions
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