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 1880e88
Showing 1 changed file with 40 additions and 0 deletions.
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 outer rescue_from :error' do
get '/alpacas'
expect(last_response.status).to eql 500
end
end

0 comments on commit 1880e88

Please sign in to comment.