Skip to content

Commit

Permalink
add failing spec for .rescue_from regression
Browse files Browse the repository at this point in the history
  • Loading branch information
dm1try authored and basjanssen committed Feb 28, 2020
1 parent cb61b27 commit fa84990
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,26 @@ def foo
expect { get '/unrescued' }.to raise_error(RuntimeError, 'beefcake')
end

it 'mimics default ruby "rescue" handler' do
# The exception is matched to the rescue starting at the top, and matches only once

subject.rescue_from ArgumentError do |e|
error!(e, 402)
end
subject.rescue_from StandardError do |e|
error!(e, 401)
end

subject.get('/child_of_standard_error') { raise ArgumentError }
subject.get('/standard_error') { raise StandardError }

get '/child_of_standard_error'
expect(last_response.status).to eql 402

get '/standard_error'
expect(last_response.status).to eql 401
end

context 'CustomError subclass of Grape::Exceptions::Base' do
before do
module ApiSpec
Expand Down

0 comments on commit fa84990

Please sign in to comment.