class DebugExceptionsTest::Boomer

Attributes

closed[RW]

Public Class Methods

new(detailed = false) click to toggle source
# File actionpack/test/dispatch/debug_exceptions_test.rb, line 9
def initialize(detailed  = false)
  @detailed = detailed
  @closed = false
end

Public Instance Methods

call(env) click to toggle source
# File actionpack/test/dispatch/debug_exceptions_test.rb, line 27
def call(env)
  env["action_dispatch.show_detailed_exceptions"] = @detailed
  req = ActionDispatch::Request.new(env)
  case req.path
  when %r{/pass}
    [404, { "X-Cascade" => "pass" }, self]
  when %r{/not_found}
    raise AbstractController::ActionNotFound
  when %r{/runtime_error}
    raise RuntimeError
  when %r{/method_not_allowed}
    raise ActionController::MethodNotAllowed
  when %r{/unknown_http_method}
    raise ActionController::UnknownHttpMethod
  when %r{/not_implemented}
    raise ActionController::NotImplemented
  when %r{/unprocessable_entity}
    raise ActionController::InvalidAuthenticityToken
  when %r{/not_found_original_exception}
    begin
      raise AbstractController::ActionNotFound.new
    rescue
      raise ActionView::Template::Error.new("template")
    end
  when %r{/missing_template}
    raise ActionView::MissingTemplate.new(%w(foo), "foo/index", %w(foo), false, "mailer")
  when %r{/bad_request}
    raise ActionController::BadRequest
  when %r{/missing_keys}
    raise ActionController::UrlGenerationError, "No route matches"
  when %r{/parameter_missing}
    raise ActionController::ParameterMissing, :missing_param_key
  when %r{/original_syntax_error}
    eval "broke_syntax =" # `eval` need for raise native SyntaxError at runtime
  when %r{/syntax_error_into_view}
    begin
      eval "broke_syntax ="
    rescue Exception
      template = ActionView::Template.new(File.read(__FILE__),
                                          __FILE__,
                                          ActionView::Template::Handlers::Raw.new,
                                          {})
      raise ActionView::Template::Error.new(template)
    end
  when %r{/framework_raises}
    method_that_raises
  else
    raise "puke!"
  end
end
close() click to toggle source
# File actionpack/test/dispatch/debug_exceptions_test.rb, line 19
def close
  @closed = true
end
each() click to toggle source

We're obliged to implement this (even though it doesn't actually get called here) to properly comply with the Rack SPEC

# File actionpack/test/dispatch/debug_exceptions_test.rb, line 16
def each
end
method_that_raises() click to toggle source
# File actionpack/test/dispatch/debug_exceptions_test.rb, line 23
def method_that_raises
  raise StandardError.new "error in framework"
end