Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added failing spec for nested rescue_from declarations #1982

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [#1976](https://github.com/ruby-grape/grape/pull/1976): Ensure classes/modules listed for autoload really exist - [@dnesteryuk](https://github.com/dnesteryuk).
* [#1971](https://github.com/ruby-grape/grape/pull/1971): Fix BigDecimal coercion - [@FlickStuart](https://github.com/FlickStuart).
* [#1968](https://github.com/ruby-grape/grape/pull/1968): Fix args forwarding in Grape::Middleware::Stack#merge_with for ruby 2.7.0 - [@dm1try](https://github.com/dm1try).
* [#1982](https://github.com/ruby-grape/grape/pull/1982): Added failing spec for nested rescue_from declarations - [@wowinter13](https://github.com/wowinter13).

### 1.3.0 (2020/01/11)

Expand Down
40 changes: 40 additions & 0 deletions spec/grape/api/nested_rescue_from_spec.rb
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