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

Identifying Slow Examples

Throughout this book, we’re going to give you advice on how to keep your specs running quickly. To understand where the biggest bottlenecks are in your suite, you need to be able to identify the slowest examples.

RSpec’s spec runner can help you do so. Consider the following group of examples that take too long to run:

 RSpec.describe ​'The sleep() method'​ ​do
 it​(​'can sleep for 0.1 second'​) { sleep 0.1 }
 it​(​'can sleep for 0.2 second'​) { sleep 0.2 }
 it​(​'can sleep for 0.3 second'​) { sleep 0.3 }
 it​(​'can sleep for 0.4 second'​) { sleep 0.4 }
 it​(​'can sleep for 0.5 second'​) { sleep 0.5 }
 end

We can ask RSpec to list the top time-wasters by passing the ...

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