'How can I pass a query string in a request spec in Rails?

This may be a very trivial question, but I have the following spec working fine for an index endpoint:

  describe 'GET api/v1/messages', type: :request do
  ...
  subject do
    get api_v1_conversation_messages_path(conversation_id),
                                                            headers: auth_headers, as: :json
end

It would be fairly equivalent to this cURL:

 curl --location --request GET '0.0.0.0:3000/api/v1/conversations/2/messages'

Now, I've added pagination with kaminari, so now, my intended format would be, for example:

 curl --location --request GET '0.0.0.0:3000/api/v1/conversations/2/messages?page=3'

This seems such a simple thing, but I can't find a way to pass this test:

    it 'checks if page is empty' do
        expect(json.size).to eq(0)
    end

(everything I've tried ends up returning a non-paginated size)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source