Defining the Ledger
We’ll start with an empty Ledger class. In your project directory, create a new file called app/ledger.rb with the following contents:
| module ExpenseTracker |
| RecordResult = Struct.new(:success?, :expense_id, :error_message) |
| |
| class Ledger |
| end |
| end |
Notice we’ve also moved the temporary RecordResult struct definition from earlier into its permanent home here. Don’t forget to delete the old version of RecordResult from spec/unit/app/api_spec.rb.
You’ll need to require this new file from app/api.rb:
| require_relative 'ledger' |
The specs you have so far are still using the fake ledger. They passed without a real Ledger ...
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.