Saving expenses is all fine and good, but it’d be nice to retrieve them. We want to allow users to fetch expenses by date, so let’s post a few expenses with different dates and then request the expenses for one of those dates. We expect the app to respond with just the expenses recorded on that date.
Posting one expense after another will get really old if we have to keep repeating all that code. Let’s extract that helper logic into a post_expense helper method inside the RSpec.describe block:
|||post '/expenses', JSON.generate(expense)|
|||parsed = JSON.parse(last_response.body) ...|