diff --git a/lib/grape/endpoint.rb b/lib/grape/endpoint.rb index 04deef72aa..f50084270e 100644 --- a/lib/grape/endpoint.rb +++ b/lib/grape/endpoint.rb @@ -404,8 +404,12 @@ def options? env[Grape::Http::Headers::REQUEST_METHOD] == Grape::Http::Headers::OPTIONS end - def method_missing(name, *args) - raise NoMethodError.new("undefined method `#{name}' for #{self.class} in `#{self.route.origin}' endpoint") + def method_missing(name, *_args) + raise NoMethodError.new("undefined method `#{name}' for #{self.class} in `#{route.origin}' endpoint") + end + + def respond_to_missing?(method_name, include_private = false) + super end end end diff --git a/spec/grape/endpoint_spec.rb b/spec/grape/endpoint_spec.rb index 26f5af0fc5..5788bd9131 100644 --- a/spec/grape/endpoint_spec.rb +++ b/spec/grape/endpoint_spec.rb @@ -698,9 +698,9 @@ def app subject.get('/hey') do undefined_helper end - expect { + expect do get '/hey' - }.to raise_error(NoMethodError, /^undefined method `undefined_helper' for # in `\/hey' endpoint/) + end.to raise_error(NoMethodError, %r{^undefined method `undefined_helper' for # in `/hey' endpoint}) end end @@ -709,9 +709,9 @@ def app subject.get('/hey') do Object.new.x end - expect { + expect do get '/hey' - }.to raise_error(NoMethodError, /^undefined method `x' for #$/) + end.to raise_error(NoMethodError, /^undefined method `x' for #$/) end end end