ruby-grape / ruby-grape/grape

Grape + Cucumber | number of arguments

Open
#2,335 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug?
Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

hello, in my tests with cucumber I have a problem.

I'm getting a wrong number of arguments (given 1, expected 0) (ArgumentError) error when I try to make a request.

I make a request that is missing parameters, I should get a 400 error with the missing parameter message.

    params do
      requires :field_a, type: Integer
      requires :field_b, type: Integer
      requires :field_c, type: Float
      requires :field_d, type: Float
      optional :active, type: Boolean
    end
    post do
      result = WorkitProductCategory.create_or_update(params)
      present result, with: Api::V1::Entities::Pmp::WorkitProductCategoryObject
    end

so is my rescue_from:

  rescue_from Grape::Exceptions::ValidationErrors do |e|
      Rails.logger.debug(e)
      error!({ error: e.message, class: e.class.name, errors: e.errors }, e.status)
    end

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the shown Grape params block, post endpoint, and rescue_from handler, then reproduce the Cucumber request that omits required parameters. Done means the request returns HTTP 400 with the missing-parameter message instead of raising the wrong-number-of-arguments error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.