Sha256: 128aff5f653943a97ed50f066f931c19c51723fbee5aea648f4c6443eccf9942

Contents?: true

Size: 1.07 KB

Versions: 90

Compression:

Stored size: 1.07 KB

Contents

require File.dirname(__FILE__) + '/helper'

class FooError < RuntimeError; end

context "Mapped errors" do

  setup do
    Sinatra.application = nil
    Sinatra.application.options.raise_errors = false
  end

  specify "are rescued and run in context" do

    error FooError do
      'MAPPED ERROR!'
    end

    get '/' do
      raise FooError
    end

    get_it '/'

    should.be.server_error
    body.should.equal 'MAPPED ERROR!'

  end

  specify "renders empty if no each method on result" do

    error FooError do
      nil
    end

    get '/' do
      raise FooError
    end

    get_it '/'

    should.be.server_error
    body.should.be.empty

  end

  specify "doesn't override status if set" do

    error FooError do
      status(200)
    end

    get '/' do
      raise FooError
    end

    get_it '/'

    should.be.ok

  end

  specify "raises errors when the raise_errors option is set" do
    Sinatra.application.options.raise_errors = true
    error FooError do
    end
    get '/' do
      raise FooError
    end
    assert_raises(FooError) { get_it('/') }
  end

end

Version data entries

90 entries across 90 versions & 14 rubygems

Version Path
nbudin-castronaut-0.7.5 vendor/sinatra/compat/mapped_error_test.rb
sinatra-0.9.6 compat/mapped_error_test.rb
sinatra-0.9.5 compat/mapped_error_test.rb
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/sinatra-0.9.4/compat/mapped_error_test.rb
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/mapped_error_test.rb
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.10.17 vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.10.16 vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.10.15 vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
middleman-0.10.14 vendor/gems/gems/sinatra-0.9.4/compat/mapped_error_test.rb
sinatra-0.9.4 compat/mapped_error_test.rb
sinatra-0.9.0.2 compat/mapped_error_test.rb
sinatra-0.9.0.1 compat/mapped_error_test.rb
sinatra-0.9.0.3 compat/mapped_error_test.rb