Querying Expenses

Let’s turn our attention to the final piece of the puzzle: querying expenses back from the database. First, you’ll need a failing spec that records a few expenses into the ledger, with some of the expenses on the same date. Querying for that date should return only the matching expenses.

Add the following specs inside the RSpec.describe block in spec/integration/app/ ledger_spec.rb:

 describe​ ​'#expenses_on'​ ​do
 it​ ​'returns all expenses for the provided date'​ ​do
  result_1 = ledger.record(expense.merge(​'date'​ => ​'2017-06-10'​))
  result_2 = ledger.record(expense.merge(​'date'​ => ​'2017-06-10'​))
  result_3 = ledger.record(expense.merge(​ ...

Get Effective Testing with RSpec 3 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.