B
B
Bogdan2018-09-03 13:40:14
Ruby on Rails
Bogdan, 2018-09-03 13:40:14

Minitest respond type?

Hello. I have a test, and for some reason it does not pass validation in the controller for the data type of the parameter, although if I pass postman data, then everything is fine. It seems like a minitest changes the type of parameters.

test 'valid get top posts' do
    body = { count: 3 }

    post '/top_posts', params: body
    assert_response :success
  end

Failure:
PostsControllerTest#test_valid_get_top_posts [/app/test/controllers/posts_controller_test.rb:34]:
Expected response to be a <2XX: success>, but was a <422: Unprocessable Entity>
Response body: {"errors":{"count":["must be an integer"]}}

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Naumenko, 2019-02-14
@NikitaNaumenko

Or can you show the controller code, and what you use for validation, judging by the error output, it looks very much like dry-validation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question