February 2013
Intermediate to advanced
272 pages
5h 45m
English
| Recipe 13 | Manipulate Time |
You want to test a long-running process, but you don’t want your tests to be slow.
Capybara[87] for testing web apps in multiple ways, both headless and in-browser
Timecop[88] for faking the time of day in Ruby
Sinatra[89] for building the sample app
One of the biggest time sinks in testing is waiting on your app. Whenever a program has to connect to a slow network, make a lengthy calculation, or wait for a specific time of day, you can speed up your tests dramatically by finding a way around the delay.
In this recipe, we’re going to write a simple web app that has a fixed delay built in. We’ll start with a slow test that waits for the app to finish its task. We’ll then look at a couple of ...