-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
After callback warning #1285
After callback warning #1285
Conversation
before | ||
begin | ||
@app_response = @app.call(@env) | ||
ensure | ||
after_response = after | ||
begin | ||
error = catch(:error) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the catch(:error) do
rack /grape specific? Otherwise I don't see why to use this instead of re-raising the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, throw is not rescued, so this is not necessary. I removed the extra catch.
👍 pls squash |
Done. |
before do | ||
@warnings = warnings = [] | ||
Grape::Middleware::Base.class_eval do | ||
define_method(:warn) { |m| warnings << m } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
allow_any_instance_of(Grape::Middleware::Base).to receive(:warn) { |m| warnings << m }
Then you don't need an after
block.
Does need a CHANGELOG entry too, please. |
Alright, done 👍 I really should have thought of |
|
||
it 'does show a warning' do | ||
expect { subject.call({}) }.to raise_error(StandardError) | ||
expect(@warnings).not_to be_empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change this, but it reads more English to say to_not
:)
Merged. |
#1265
See discussion in the issue...