Sha256: 367d412afbb95a3e96abc9950b4b99922103fd21109c71f8c76a2d0d1bd5c84e

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

#          Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

require 'spec/spec_helper'
require 'open-uri'

class TCErrorController < Ramaze::Controller
  trait :public => 'spec/public'

  def index
    self.class.name
  end
end

context "Error" do
  context "in dispatcher" do
    ramaze :mapping => {'/' => TCErrorController }, :error_page => true

    specify "your illegal stuff" do
      Ramaze::Dispatcher.trait[:handle_error] = { Exception => '/error', }

      lambda{ get('/illegal') }.should_raise RuntimeError
    end
  end

  context "no controller" do
    specify "your illegal stuff" do
      Ramaze::Global.mapping = {}
      Ramaze::Dispatcher.trait[:handle_error] = { Exception => '/error', }

      lambda{ get('/illegal') }.should_raise RuntimeError
    end
  end

  context "only error page (custom)" do
    specify "custom static page" do
      Ramaze::Global.mapping = {'/' => TCErrorController }
      Ramaze::Dispatcher.trait[:handle_error] = { Exception => '/error404', }

      get('/foo').should == '404 - not found'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ramaze-0.0.9 spec/tc_error.rb