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

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

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