GithubHelp home page GithubHelp logo

grape-route-helpers's People

Contributors

phallguy avatar reprah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grape-route-helpers's Issues

Searching for helper stops with first possible match

We have a route :id/repository/tags and a route :id/repository/tags/:tag_name, both generate the route helper api_v4_projects_repository_tags_path.

Calling api_v4_projects_repository_tags_path(id: 123) returns /api/v4/projects/123/repository/tags, but calling api_v4_projects_repository_tags_path(id: 123, tag_name: 'foo') returns the exact same path. While it actually should return /api/v4/projects/123/repository/tags/foo.

We have the grape endpoint defined get ':id/repository/tags' first and get ':id/repository/tags/:tag_name' below that. If we swap the order, the correct route helper is found and the correct path is returned depending on the parameters.

See the full grape definition here:
https://gitlab.com/gitlab-org/gitlab-ce/blob/547b458e254bdb271d8ff41e62217fa7f3cf9c87/lib/api/tags.rb#L13-40

Cannot add multiple POST routes in a resource

Looks like the options hash of grape routes does not contain the specific path name in it only the namespace.

resource :hamlet do
  post :tobe do
   "to be"
  end
  post :ornot do
    "or not"
  end
end

Submitted a PR #13

Version with dash causes SyntaxError

When an API version contains a dash (v1-draft), it causes an issue at decorator creation:

syntax error, unexpected '-', expecting ';' or '\n'
        def infra_v1-draft_version_path(attributes = {})
                     ^
(eval):10: syntax error, unexpected keyword_end, expecting end-of-input

Add helpers for getting current endpoint

It would be nice if there would be a helper for getting the path of the current endpoint, like:

class ExampleAPI < Grape::API
  version 'v1'
  prefix 'api'
  format 'json'

  resource :cats do
    get '/' do
      current_path # returns the same thing as api_v1_cats_path
    end
  end

  resource :dogs do
    get '/' do
      current_path # returns the same thing as api_v1_dogs_path
    end
  end
end

My use case would be constructing pagination links. For that I always need to get the path of the current endpoint being used and add some query parameters to it.

Willing to accept new maintainers?

@reprah Thanks for your work on this gem.

We've found some things that cause pretty big performance problems and would like to contribute fixes upstream. This projects has been pretty dormant lately so I would like to offer to help you maintain this if you're still interested in keeping this updated.

Are you interested in taking on an additional maintainer to keep this alive? We don't have a problem with forking and releasing fixes under another gem name, but of course we want to be good OSS stewards, too, and do what is best for the community. Keeping this existing project/gem would definitely be the ideal solution.

I look forward to your thoughts. Thanks for your consideration.

test failure with grape 0.19.2

We'd like to use grape 0.19.2 in debian as gitlab needs it.

$ bundle exec rake
/usr/bin/ruby2.3 -I/home/pravi/forge/debian/git/pkg-ruby-extras/ruby-grape-route-helpers/vendor/bundle/gems/rspec-core-3.3.1/lib:/home/pravi/forge/debian/git/pkg-ruby-extras/ruby-grape-route-helpers/vendor/bundle/gems/rspec-support-3.3.0/lib /home/pravi/forge/debian/git/pkg-ruby-extras/ruby-grape-route-helpers/vendor/bundle/gems/rspec-core-3.3.1/exe/rspec --pattern spec/\*\*/\*_spec.rb
.......F.......F........F.FFFFFFFFFFF.FF

Failures:

  1) GrapeRouteHelpers::DecoratedRoute#helper_names when an API has multiple versions returns the route's helper name for each version
     Failure/Error: described_class.new(route)
     NoMethodError:
       undefined method `scan' for ["beta", "alpha", "v1"]:Array
     # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
     # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
     # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:8:in `new'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:8:in `block (3 levels) in <top (required)>'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:7:in `map'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:29:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:75:in `block (4 levels) in <top (required)>'

  2) GrapeRouteHelpers::DecoratedRoute#path_helper_name when the path is a catch-all path returns a name without the glob star
     Failure/Error: expect(result).to eq('api_v1_path_path')
       
       expected: "api_v1_path_path"
            got: "api_v1___path_path"
       
       (compared using ==)
     # ./spec/grape_route_helpers/decorated_route_spec.rb:147:in `block (4 levels) in <top (required)>'

  3) GrapeRouteHelpers::DecoratedRoute path helper method when a route's API has multiple versions returns a path for each version
     Failure/Error: described_class.new(route)
     NoMethodError:
       undefined method `scan' for ["beta", "alpha", "v1"]:Array
     # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
     # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
     # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:8:in `new'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:8:in `block (3 levels) in <top (required)>'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:7:in `map'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:29:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/decorated_route_spec.rb:222:in `block (4 levels) in <top (required)>'

  4) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name returns true
     Failure/Error: Grape::API.decorated_routes
     NoMethodError:
       undefined method `scan' for ["beta", "alpha", "v1"]:Array
     # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
     # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
     # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:30:in `block (4 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:43:in `block (4 levels) in <top (required)>'

  5) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when segments is not a hash raises an ArgumentError
     Failure/Error: expect do
       expected ArgumentError, got #<NoMethodError: undefined method `scan' for ["beta", "alpha", "v1"]:Array> with backtrace:
         # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
         # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
         # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
         # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
         # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
         # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
         # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
         # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
         # ./spec/grape_route_helpers/named_route_matcher_spec.rb:11:in `block (2 levels) in <top (required)>'
         # ./spec/grape_route_helpers/named_route_matcher_spec.rb:30:in `block (4 levels) in <top (required)>'
         # ./spec/grape_route_helpers/named_route_matcher_spec.rb:37:in `block (6 levels) in <top (required)>'
         # ./spec/grape_route_helpers/named_route_matcher_spec.rb:36:in `block (5 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:36:in `block (5 levels) in <top (required)>'

  6) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options returns true
     Failure/Error: Grape::API.decorated_routes
     NoMethodError:
       undefined method `scan' for ["beta", "alpha", "v1"]:Array
     # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
     # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
     # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:30:in `block (4 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:51:in `block (5 levels) in <top (required)>'

  7) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options when no dynamic segments are requested when the route requires dynamic segments returns false
     Failure/Error: Grape::API.decorated_routes
     NoMethodError:
       undefined method `scan' for ["beta", "alpha", "v1"]:Array
     # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
     # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
     # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:23:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:57:in `block (7 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:61:in `block (7 levels) in <top (required)>'

  8) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options when no dynamic segments are requested when the route does not require dynamic segments returns true
     Failure/Error: Grape::API.decorated_routes
     NoMethodError:
       undefined method `scan' for ["beta", "alpha", "v1"]:Array
     # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
     # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
     # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:30:in `block (4 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:68:in `block (7 levels) in <top (required)>'

  9) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options when route requires the requested segments returns true
     Failure/Error: Grape::API.decorated_routes
     NoMethodError:
       undefined method `scan' for ["beta", "alpha", "v1"]:Array
     # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
     # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
     # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
     # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:23:in `block (2 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:75:in `block (6 levels) in <top (required)>'
     # ./spec/grape_route_helpers/named_route_matcher_spec.rb:80:in `block (6 levels) in <top (required)>'

  10) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options when route does not require the requested segments returns false
      Failure/Error: Grape::API.decorated_routes
      NoMethodError:
        undefined method `scan' for ["beta", "alpha", "v1"]:Array
      # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
      # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
      # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:11:in `block (2 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:30:in `block (4 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:89:in `block (6 levels) in <top (required)>'

  11) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when segments contains unexpected options returns false
      Failure/Error: Grape::API.decorated_routes
      NoMethodError:
        undefined method `scan' for ["beta", "alpha", "v1"]:Array
      # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
      # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
      # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:11:in `block (2 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:30:in `block (4 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:99:in `block (5 levels) in <top (required)>'

  12) GrapeRouteHelpers::NamedRouteMatcher#route_match? when route does not respond to a method name returns false
      Failure/Error: Grape::API.decorated_routes
      NoMethodError:
        undefined method `scan' for ["beta", "alpha", "v1"]:Array
      # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
      # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
      # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:11:in `block (2 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:107:in `block (4 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:111:in `block (4 levels) in <top (required)>'

  13) GrapeRouteHelpers::NamedRouteMatcher#method_missing when method name matches a Grape::Route path helper name returns the path for that route object
      Failure/Error: path = api_v1_ping_path
      NoMethodError:
        undefined method `scan' for ["beta", "alpha", "v1"]:Array
      # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
      # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
      # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
      # ./lib/grape-route-helpers/named_route_matcher.rb:10:in `method_missing'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:120:in `block (4 levels) in <top (required)>'

  14) GrapeRouteHelpers::NamedRouteMatcher#method_missing when method name matches a Grape::Route path helper name when argument to the helper is not a hash raises an ArgumentError
      Failure/Error: expect do
        expected ArgumentError, got #<NoMethodError: undefined method `scan' for ["beta", "alpha", "v1"]:Array> with backtrace:
          # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
          # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
          # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
          # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
          # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
          # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
          # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
          # ./lib/grape-route-helpers/named_route_matcher.rb:10:in `method_missing'
          # ./spec/grape_route_helpers/named_route_matcher_spec.rb:127:in `block (6 levels) in <top (required)>'
          # ./spec/grape_route_helpers/named_route_matcher_spec.rb:126:in `block (5 levels) in <top (required)>'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:126:in `block (5 levels) in <top (required)>'

  15) GrapeRouteHelpers::NamedRouteMatcher when Grape::Route objects share the same helper name when helpers require different segments to generate their path uses arguments to infer which route to use
      Failure/Error: show_path = api_v1_cats_path('id' => 1)
      NoMethodError:
        undefined method `scan' for ["beta", "alpha", "v1"]:Array
      # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
      # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
      # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
      # ./lib/grape-route-helpers/named_route_matcher.rb:10:in `method_missing'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:145:in `block (4 levels) in <top (required)>'

  16) GrapeRouteHelpers::NamedRouteMatcher when Grape::Route objects share the same helper name when query params are passed in uses arguments to infer which route to use
      Failure/Error: show_path = api_v1_cats_path('id' => 1, params: { 'foo' => 'bar' })
      NoMethodError:
        undefined method `scan' for ["beta", "alpha", "v1"]:Array
      # ./lib/grape-route-helpers/decorated_route.rb:69:in `route_versions'
      # ./lib/grape-route-helpers/decorated_route.rb:33:in `define_path_helpers'
      # ./lib/grape-route-helpers/decorated_route.rb:17:in `initialize'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `new'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `block in decorated_routes'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `map'
      # ./lib/grape-route-helpers/all_routes.rb:8:in `decorated_routes'
      # ./lib/grape-route-helpers/named_route_matcher.rb:10:in `method_missing'
      # ./spec/grape_route_helpers/named_route_matcher_spec.rb:155:in `block (4 levels) in <top (required)>'

Finished in 0.16183 seconds (files took 0.51 seconds to load)
40 examples, 16 failures

Failed examples:

rspec ./spec/grape_route_helpers/decorated_route_spec.rb:74 # GrapeRouteHelpers::DecoratedRoute#helper_names when an API has multiple versions returns the route's helper name for each version
rspec ./spec/grape_route_helpers/decorated_route_spec.rb:145 # GrapeRouteHelpers::DecoratedRoute#path_helper_name when the path is a catch-all path returns a name without the glob star
rspec ./spec/grape_route_helpers/decorated_route_spec.rb:221 # GrapeRouteHelpers::DecoratedRoute path helper method when a route's API has multiple versions returns a path for each version
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:42 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name returns true
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:35 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when segments is not a hash raises an ArgumentError
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:50 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options returns true
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:60 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options when no dynamic segments are requested when the route requires dynamic segments returns false
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:67 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options when no dynamic segments are requested when the route does not require dynamic segments returns true
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:79 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options when route requires the requested segments returns true
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:88 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when requested segments contains expected options when route does not require the requested segments returns false
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:98 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route responds to a method name when segments contains unexpected options returns false
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:110 # GrapeRouteHelpers::NamedRouteMatcher#route_match? when route does not respond to a method name returns false
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:119 # GrapeRouteHelpers::NamedRouteMatcher#method_missing when method name matches a Grape::Route path helper name returns the path for that route object
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:125 # GrapeRouteHelpers::NamedRouteMatcher#method_missing when method name matches a Grape::Route path helper name when argument to the helper is not a hash raises an ArgumentError
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:144 # GrapeRouteHelpers::NamedRouteMatcher when Grape::Route objects share the same helper name when helpers require different segments to generate their path uses arguments to infer which route to use
rspec ./spec/grape_route_helpers/named_route_matcher_spec.rb:154 # GrapeRouteHelpers::NamedRouteMatcher when Grape::Route objects share the same helper name when query params are passed in uses arguments to infer which route to use

/usr/bin/ruby2.3 -I/home/pravi/forge/debian/git/pkg-ruby-extras/ruby-grape-route-helpers/vendor/bundle/gems/rspec-core-3.3.1/lib:/home/pravi/forge/debian/git/pkg-ruby-extras/ruby-grape-route-helpers/vendor/bundle/gems/rspec-support-3.3.0/lib /home/pravi/forge/debian/git/pkg-ruby-extras/ruby-grape-route-helpers/vendor/bundle/gems/rspec-core-3.3.1/exe/rspec --pattern spec/\*\*/\*_spec.rb failed

Add support for url helpers

Helper methods only return the path, minus the hostname. Helper methods ending in url instead of path should return the protocol + host + path.

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

  1. Define a multi-version Grape API such as version %w(v3 v4), using: :path
  2. 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?

Make grape-route-helpers compatible with grape 0.16.0

Someone made a PR when they noticed that upgrading to grape 0.16.x broke the gem. Grape changed a few things in their Grape::Route class. There were also some deprecation warnings.

This is fixed in version 2.0.0; I made this issue just to document it was a problem at one point.

route helpers sometimes return route with extension, and sometimes do not

When running tests for an app, sometimes the grape route helpers return a string with the extension for the route appended (expected behavior), and sometimes they do not (not expected). This causes tests to fail for code that generates a payload with callback URLs using grape route helpers, because the return value is not consistent.

Any ideas why this would be happening? I suspect it is a load order issue but I have not been able to identify the specific culprit yet as it only happens 1:20 builds; however, when it does occur we see all tests that rely on grape route helpers fail, not just one or two intermittent failures within the specs.

Add support for query string parameters

Additional key/value pairs passed to a helper method should be turned into query string parameters.

Example:

  cats_path(order_by: 'age', fed: false) # => should return '/cats?order_by=age&fed=false'

Subdomain

Hi,
How can I use it with subdomain?
For example a have route: api.example.com/v1/users

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.