class ActionDispatch::IntegrationTest

Public Class Methods

build_app(routes = nil) { |middleware| ... } click to toggle source
# File test/abstract_unit.rb, line 105
def self.build_app(routes = nil)
  RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
    middleware.use "ActionDispatch::ShowExceptions", ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
    middleware.use "ActionDispatch::Callbacks"
    middleware.use "ActionDispatch::ParamsParser"
    middleware.use "ActionDispatch::Cookies"
    middleware.use "ActionDispatch::Flash"
    middleware.use "ActionDispatch::Head"
    yield(middleware) if block_given?
  end
end
stub_controllers() { |route_set| ... } click to toggle source
# File test/abstract_unit.rb, line 132
def self.stub_controllers
  old_dispatcher = ActionDispatch::Routing::RouteSet::Dispatcher
  ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
  ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, StubDispatcher }
  yield ActionDispatch::Routing::RouteSet.new
ensure
  ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
  ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, old_dispatcher }
end

Public Instance Methods

with_autoload_path(path) { || ... } click to toggle source
# File test/abstract_unit.rb, line 154
def with_autoload_path(path)
  path = File.join(File.dirname(__FILE__), "fixtures", path)
  if ActiveSupport::Dependencies.autoload_paths.include?(path)
    yield
  else
    begin
      ActiveSupport::Dependencies.autoload_paths << path
      yield
    ensure
      ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
      ActiveSupport::Dependencies.clear
    end
  end
end
with_routing() { |temporary_routes| ... } click to toggle source
# File test/abstract_unit.rb, line 142
def with_routing(&block)
  temporary_routes = ActionDispatch::Routing::RouteSet.new
  old_app, self.class.app = self.class.app, self.class.build_app(temporary_routes)
  old_routes = SharedTestRoutes
  silence_warnings { Object.const_set(:SharedTestRoutes, temporary_routes) }

  yield temporary_routes
ensure
  self.class.app = old_app
  silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
end