Topic: Cucumber + Intentional Exception

Hello all.

I have the following in my application controller.

  unless ActionController::Base.consider_all_requests_local
    rescue_from Exception,                            :with => :render_error
    rescue_from ActiveRecord::RecordNotFound,         :with => :render_not_found
    rescue_from ActionController::RoutingError,       :with => :render_not_found
    rescue_from ActionController::UnknownController,  :with => :render_not_found
    rescue_from ActionController::UnknownAction,      :with => :render_not_found

  def render_not_found
    render :template => "/error/404.html.haml", :status => 404, :layout => "application"

  def render_error
    render :template => "/error/500.html.haml", :status => 500, :layout => "application"

Now I want to write some cucumber tests to make sure the 404 and 500 pages are being displayed. Testing the 404 is easy because you just have to visit a non-existent page with the @allow-rescue tag in the cucumber test.

Testing a 500 though is something I cannot figure out? Is there a way to simulate throwing the generic Exception so that we can test it with cucumber?

Last edited by RurouniJones (2010-08-01 22:58:03)