have invoke raise ArgumentErrors instead of TypeErrors
This commit is contained in:
parent
8f1c7bca96
commit
b10b80c28e
|
@ -727,7 +727,7 @@ module Sinatra
|
||||||
res = catch(:halt) { yield }
|
res = catch(:halt) { yield }
|
||||||
res = [res] if Fixnum === res or String === res
|
res = [res] if Fixnum === res or String === res
|
||||||
if Array === res and Fixnum === res.first
|
if Array === res and Fixnum === res.first
|
||||||
raise TypeError, "#{res.inspect} not supported" if res.length > 3
|
raise ArgumentError, "#{res.inspect} not supported" if res.length > 3
|
||||||
status(res.shift)
|
status(res.shift)
|
||||||
body(res.pop)
|
body(res.pop)
|
||||||
headers(*res)
|
headers(*res)
|
||||||
|
|
|
@ -76,14 +76,14 @@ class ResultTest < Test::Unit::TestCase
|
||||||
assert_equal 'formula of', body
|
assert_equal 'formula of', body
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises a TypeError when result is a non two or three tuple Array" do
|
it "raises a ArgumentError when result is a non two or three tuple Array" do
|
||||||
mock_app {
|
mock_app {
|
||||||
get '/' do
|
get '/' do
|
||||||
[409, 'formula of', 'something else', 'even more']
|
[409, 'formula of', 'something else', 'even more']
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_raise(TypeError) { get '/' }
|
assert_raise(ArgumentError) { get '/' }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets status when result is a Fixnum status code" do
|
it "sets status when result is a Fixnum status code" do
|
||||||
|
|
Loading…
Reference in New Issue