Sha256: 535016d7dd96815a49901ce4fccb0eea475ff80c57986c26408f1b3935f0746c

Contents?: true

Size: 1004 Bytes

Versions: 10

Compression:

Stored size: 1004 Bytes

Contents

require 'assert'
require 'deas/show_exceptions'

require 'rack/utils'

class Deas::ShowExceptions

  class UnitTests < Assert::Context
    desc "Deas::ShowExceptions"
    setup do
      exception = Sinatra::NotFound.new
      @app = proc do |env|
        env['sinatra.error'] = exception
        [ 404, {}, [] ]
      end
      @exception = exception
      @show_exceptions = Deas::ShowExceptions.new(@app)
    end
    subject{ @show_exceptions }

    should have_imeths :call, :call!

    should "return a body that contains details about the exception" do
      status, headers, body = subject.call({})
      expected_body = "#{@exception.class}: #{@exception.message}\n" \
                      "#{(@exception.backtrace || []).join("\n")}"
      expected_body_size = Rack::Utils.bytesize(expected_body).to_s

      assert_equal expected_body_size, headers['Content-Length']
      assert_equal "text/plain",       headers['Content-Type']
      assert_equal [expected_body],    body
    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
deas-0.37.0 test/unit/show_exceptions_tests.rb
deas-0.36.0 test/unit/show_exceptions_tests.rb
deas-0.35.0 test/unit/show_exceptions_tests.rb
deas-0.34.0 test/unit/show_exceptions_tests.rb
deas-0.33.0 test/unit/show_exceptions_tests.rb
deas-0.32.0 test/unit/show_exceptions_tests.rb
deas-0.31.0 test/unit/show_exceptions_tests.rb
deas-0.30.0 test/unit/show_exceptions_tests.rb
deas-0.29.0 test/unit/show_exceptions_tests.rb
deas-0.28.0 test/unit/show_exceptions_tests.rb