Permalink
Browse files

All on one abstract_unit

  • Loading branch information...
1 parent a6f19a1 commit f05b1e5eb1829be47bf9581ca6666229e01d597c @josh josh committed Sep 19, 2009
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module AbstractController
module Testing
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module AbstractController
module Testing
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module AbstractController
module Testing
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
require 'active_support/core_ext/class/removal'
module AbstractControllerTests
@@ -16,15 +16,17 @@
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 @@
# 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 @@ class TestCase
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 @@ def assert_template(options = {}, message = nil)
end
end
end
+
+
+class SimpleRouteCase < Rack::TestCase
+ setup do
+ ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+ end
+ end
+end
@@ -1,119 +0,0 @@
-# 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')
-
-require 'bundler_helper'
-ensure_requirable %w( rack rack/test )
-
-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
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
# Tests the controller dispatching happy path
module Dispatching
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module ContentNegotiation
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module ContentType
class BaseController < ActionController::Base
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module Etags
class BasicController < ActionController::Base
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module MetalTest
class MetalMiddleware < ActionController::Middleware
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module MiddlewareTest
class MyMiddleware
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderAction
# This has no layout and it works
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderFile
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderImplicitAction
class SimpleController < ::ApplicationController
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module ControllerLayouts
class ImplicitController < ::ApplicationController
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderPartial
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderRjs
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderTemplate
class WithoutLayoutController < ActionController::Base
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module Render
class BlankRenderController < ActionController::Base
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderText
class SimpleController < ActionController::Base
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderXml

0 comments on commit f05b1e5

Please sign in to comment.