diff --git a/lib/grape-route-helpers/all_routes.rb b/lib/grape-route-helpers/all_routes.rb index a71bae7..ed2cddc 100644 --- a/lib/grape-route-helpers/all_routes.rb +++ b/lib/grape-route-helpers/all_routes.rb @@ -11,9 +11,8 @@ def decorated_routes def all_routes routes = subclasses.flat_map { |s| s.send(:prepare_routes) } # delete duplicate routes - routes.delete_if do |route| - all_options = routes.map { |r| r.instance_variable_get(:@options) } - all_options.count(route.instance_variable_get(:@options)) > 1 + routes.uniq do |route| + route.instance_variable_get(:@options) end end end diff --git a/spec/support/api.rb b/spec/support/api.rb index 763213b..2f02dcc 100644 --- a/spec/support/api.rb +++ b/spec/support/api.rb @@ -14,6 +14,10 @@ class API < Grape::API 'pong' end + get 'ping' do + 'pong' + end + resource :cats do get '/' do %w(cats cats cats)