O'Reilly logo

Effective Testing with RSpec 3 by Myron Marston, Ian Dees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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(​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required