Deciding What to Test First
Even this simple app has several pieces. It’s easy to feel overwhelmed as we’re deciding what to test first. Where do we start?
To drive the first example, ask yourself: what’s the core of the project? What’s the one thing we agree our API should do? It should faithfully save the expenses we record.
Let’s encode the first part of that desired behavior in a spec, and then implement the behavior. Place the following code in spec/acceptance/expense_tracker_api_spec.rb:
| require 'rack/test' |
| require 'json' |
| |
| module ExpenseTracker |
| RSpec.describe 'Expense Tracker API' do |
| include Rack::Test::Methods |
| |
| it 'records submitted ... |
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.