Projects
Mega:23.09
rubygem-sinatra
_service:tar_scm:Internal-Sinatra-errors-now-ex...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:Internal-Sinatra-errors-now-extend-Sinatra-Error-test.patch of Package rubygem-sinatra
From d8c35ce7bc6320e5805b106e1bec39d0b64b9306 Mon Sep 17 00:00:00 2001 From: Jordan Owens <jkowens@gmail.com> Date: Thu, 31 Jan 2019 22:32:45 -0500 Subject: [PATCH] Internal Sinatra errors now extend Sinatra::Error --- test/mapped_error_test.rb | 6 +++--- test/result_test.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/mapped_error_test.rb b/test/mapped_error_test.rb index cb158a2..562e509 100644 --- a/test/mapped_error_test.rb +++ b/test/mapped_error_test.rb @@ -6,15 +6,15 @@ end class FooNotFound < Sinatra::NotFound end -class FooSpecialError < RuntimeError +class FooSpecialError < Sinatra::Error def http_status; 501 end end -class FooStatusOutOfRangeError < RuntimeError +class FooStatusOutOfRangeError < Sinatra::Error def code; 4000 end end -class FooWithCode < RuntimeError +class FooWithCode < Sinatra::Error def code; 419 end end diff --git a/test/result_test.rb b/test/result_test.rb index cbb7813..cc9990f 100644 --- a/test/result_test.rb +++ b/test/result_test.rb @@ -1,5 +1,9 @@ require File.expand_path('../helper', __FILE__) +class ThirdPartyError < RuntimeError + def http_status; 400 end +end + class ResultTest < Minitest::Test it "sets response.body when result is a String" do mock_app { get('/') { 'Hello World' } } @@ -73,4 +77,15 @@ class ResultTest < Minitest::Test assert_equal 205, status assert_equal '', body end + + it "sets status to 500 when raised error is not Sinatra::Error" do + mock_app do + set :raise_errors, false + get('/') { raise ThirdPartyError } + end + + get '/' + assert_equal 500, status + assert_equal '<h1>Internal Server Error</h1>', body + end end -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2