Multi-version API helper method lookup error
Grape gives the ability to define multi-version API's with fallbacks (i.e. if one hits an endpoint that doesn't exists, it goes up or down a version: version %w(v3 v4), using: :path). Using the array version definition in order to achieve that make it impossible to use grape-route-helpers, which raises NoMethodError: undefined method scan for ['v3', 'v4']:Array in the lookup process.
Steps to reproduce
- Define a multi-version Grape API such as
version %w(v3 v4), using: :path - Run
rake grape:route_helpers
At this point it will raise NoMethodError: undefined method scan for ['v3', 'v4']:Array. I'm not sure if always taking the last element on the array will make sense in every scenario. I'm willing to work on it, any suggestions?
Update: For some reason on tests route_version reaches as a String on the following method:
def route_versions
version_pattern = /[^\[",\]\s]+/
if route_version
route_version.scan(version_pattern)
else
[nil]
end
end
While outside tests, route_version is an Array.