Sha256: 0e0675f62fa22dc902fdcc824dd1420d8af2a2b5822a02e64b0addb7ac3fa6cc
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require_relative 'helper' class ErrorsTest < ApiTest class App < Jersey::API::Base get '/test-409' do raise Conflict, "bad" end get '/test-500' do raise InternalServerError, "bad" end get '/test-runtime-error' do raise "boom!" end end def test_not_found get '/not-found' assert_equal(404, last_response.status) assert_equal('NotFound', json['error']['type']) end def test_http_errors_409 get '/test-409' assert_equal(409, last_response.status) assert_equal('Conflict', json['error']['type']) assert_equal('bad', json['error']['message']) assert(json['error']['request_id']) end def test_http_errors_500 get '/test-500' assert_equal(500, last_response.status) assert_equal('InternalServerError', json['error']['type']) assert_equal('bad', json['error']['message']) assert(json['error']['request_id']) end def test_http_errors_Undefined get '/test-runtime-error' assert_equal(500, last_response.status) assert_equal('RuntimeError', json['error']['type']) assert_equal('boom!', json['error']['message']) assert(json['error']['request_id']) end def test_errors_are_logged Jersey.logger.stream = StringIO.new get '/test-500' loglines = logs.lines assert_equal(2, loglines.size) logdata = Logfmt.parse(loglines[0]) assert(logdata['at'], 'started') logdata = Logfmt.parse(loglines[1]) assert(logdata['at'], 'finished') assert(logdata['status'], '500') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jersey-0.2.0 | test/errors_test.rb |
jersey-0.1.0 | test/errors_test.rb |