Skip to content

Commit

Permalink
Added failing spec for nested rescue_from declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
wowinter13 committed Jan 21, 2020
1 parent 8e0b232 commit c55a9c7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
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

0 comments on commit c55a9c7

Please sign in to comment.