From 1880e883cd22046cd26e6cd221eb1c2e2a7b1b43 Mon Sep 17 00:00:00 2001 From: wowinter13 Date: Tue, 21 Jan 2020 19:37:32 +0300 Subject: [PATCH] Added failing spec for nested rescue_from declarations --- spec/grape/api/nested_rescue_from_spec.rb | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/grape/api/nested_rescue_from_spec.rb diff --git a/spec/grape/api/nested_rescue_from_spec.rb b/spec/grape/api/nested_rescue_from_spec.rb new file mode 100644 index 0000000000..686912154b --- /dev/null +++ b/spec/grape/api/nested_rescue_from_spec.rb @@ -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 outer rescue_from :error' do + get '/alpacas' + expect(last_response.status).to eql 500 + end +end