The first method we will test is the index action in Shopping List Controller. This test will make a GET request to /shopping_lists, which will invoke the index action. The index action should return all of the Shopping Lists in the database, and, since we do not have any entries when we run the test, we should get back an empty array as the response. To add this test, perform the following steps:
- First, create a new method called testShoppingListIndex:
func testShoppingListIndex() throws {}
- Next, add the following code inside this newly created method that will make a GET request to /shopping_lists. It will then assert that the response body is an empty array:
try drop .testResponse(to: .get, at: "/shopping_lists") ...