Skip to content

Can't use coerce_with and Array[Integer] or Array[String] param types #1324

Closed
@ngonzalez

Description

@ngonzalez

Hello,

we're having trouble using coerce_with helper since this commit: 7411e2f

Here is a test showing the problem we have:
https://github.com/ngonzalez/grape-test-app/blob/master/test/controllers/api_test.rb
https://github.com/ngonzalez/grape-test-app/blob/master/app/api/twitter/api.rb

# Running:

F...

Finished in 0.188642s, 21.2042 runs/s, 37.1073 assertions/s.

  1) Failure:
ApiTest#test_test_2 [/home/ngonzalez/Sites/grape-test-app/test/controllers/api_test.rb:18]:
Expected: [1, 2, 3, 4]
  Actual: {"error"=>"values is invalid"}

4 runs, 7 assertions, 1 failures, 0 errors, 0 skips

Array type is working fine with coerce_with but we need Array[Integer]

We have a branch with the same test and Grape version freezed:
https://github.com/ngonzalez/grape-test-app/compare/before-changes

In this branch, tests pass without errors:

# Running:

....

Finished in 0.197692s, 20.2335 runs/s, 40.4669 assertions/s.

4 runs, 8 assertions, 0 failures, 0 errors, 0 skips

Is Array[Integer] going to be fixed in future versions of Grape ?

Thanks

Nicolas Gonzalez

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions