In Ruby is extremely important to test everything, why? Because it’s an interpreted language and is dynamically typed, so errors will pop up at runtime (it could be production ☠️).

Apart from code errors if we change the response of an endpoint it’s very probable that we will break the client apps. So remember! At least 1 test for each endpoint.

And why Minitest? It’s fast, simple and you already know Ruby 💎

Now imagine we have a simple endpoint at /api/v1/cars to return the cars available in our database. Let’s see how to do it with a simple integration test:

require 'test_helper'

class Api::V1::CarsTest < ActionDispatch::IntegrationTest
  test 'get a list of cars' do     
    get api_v1_cars_path

    assert_response :success  
    
    cars = JSON.parse(response.body).dig('cars')
      
    assert_equal cars.length, 3

    assert_equal 'Dacia', cars.first.dig('name')
  end
end

For the dummy data on your tests, you can use Rails fixtures or FactoryBot.