GrapeSwagger::DocMethods::Extensions breaks the contract of Kernel#method (#760)
* GrapeSwagger::DocMethods::Extensions breaks the contract of Kernel#method This causes code inspection tools and development workflows to break and may cause developers to choose not to use the gem. * add test for method introspection on GrapeSwagger::DocMethods::Extensions * fix ci lint failure
This commit is contained in:
parent
d7bf077802
commit
3de44a3a6f
|
@ -87,7 +87,12 @@ module GrapeSwagger
|
|||
part.select { |x| x == identifier }
|
||||
end
|
||||
|
||||
def method
|
||||
def method(*args)
|
||||
# We're shadowing Object.method(:symbol) here so we provide
|
||||
# a compatibility layer for code that introspects the methods
|
||||
# of this class
|
||||
return super if args.size.positive?
|
||||
|
||||
@route.request_method.downcase.to_sym
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GrapeSwagger::DocMethods::Extensions do
|
||||
context 'it should not break method introspection' do
|
||||
describe '.method' do
|
||||
describe 'method introspection' do
|
||||
specify do
|
||||
expect(described_class.method(described_class.methods.first)).to be_a(Method)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#find_definition' do
|
||||
subject { described_class }
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ describe 'document hash and array' do
|
|||
class TestApi < Grape::API
|
||||
format :json
|
||||
|
||||
documentation = ::Entities::DocumentedHashAndArrayModel.documentation if ::Entities::DocumentedHashAndArrayModel.respond_to?(:documentation)
|
||||
if ::Entities::DocumentedHashAndArrayModel.respond_to?(:documentation)
|
||||
documentation = ::Entities::DocumentedHashAndArrayModel.documentation
|
||||
end
|
||||
|
||||
desc 'This returns something'
|
||||
namespace :arbitrary do
|
||||
|
|
Loading…
Reference in New Issue