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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.