-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added failing spec for nested rescue_from declarations
- Loading branch information
1 parent
8e0b232
commit c55a9c7
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
# see https://github.com/ruby-grape/grape/issues/1975 | ||
|
||
require 'spec_helper' | ||
|
||
module NestedRescueFromSpec | ||
class Alpacas < Grape::API | ||
resource :alpacas do | ||
rescue_from :all do | ||
error_response(status: 200) | ||
end | ||
|
||
get do | ||
{ count_alpacas: 1 / 0 } | ||
end | ||
end | ||
end | ||
|
||
class Main < Grape::API | ||
rescue_from ZeroDivisionError do | ||
error_response(status: 500) | ||
end | ||
|
||
mount NestedRescueFromSpec::Alpacas | ||
end | ||
end | ||
|
||
describe Grape::API do | ||
subject { NestedRescueFromSpec::Main } | ||
|
||
def app | ||
subject | ||
end | ||
|
||
it 'calls the inner rescue_from :all from Alpacas class' do | ||
get '/alpacas' | ||
expect(last_response.status).to eql 200 | ||
end | ||
end |