Skip to content

Commit

Permalink
Remove expect_any_instance_of(...)
Browse files Browse the repository at this point in the history
Wrap `default_rescue_handler` with `method`
  • Loading branch information
ericproulx committed Jul 23, 2024
1 parent fb67ea9 commit 9dce428
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion lib/grape/middleware/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def run_rescue_handler(handler, error, endpoint)
elsif response.is_a?(Rack::Response)
response
else
run_rescue_handler(:default_rescue_handler, Grape::Exceptions::InvalidResponse.new, endpoint)
run_rescue_handler(method(:default_rescue_handler), Grape::Exceptions::InvalidResponse.new, endpoint)
end
end

Expand Down
2 changes: 0 additions & 2 deletions spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2196,8 +2196,6 @@ def foo
it 'uses default_rescue_handler to handle invalid response from rescue_from' do
subject.rescue_from(:all) { 'error' }
subject.get('/') { raise }

expect_any_instance_of(Grape::Middleware::Error).to receive(:default_rescue_handler).and_call_original
get '/'
expect(last_response).to be_server_error
expect(last_response.body).to eql 'Invalid response'
Expand Down

0 comments on commit 9dce428

Please sign in to comment.