Running Our Test

Having written our first test, we’d like to execute it. Although RSpec provides Rake tasks for executing RSpec, I recommend using the rspec command directly to avoid the overhead of starting up Rake. If you use rspec with no arguments, then RSpec will run over the entire spec directory. You can also give RSpec an individual file, directory, or line to run. For full details on those options, see Chapter 15, ​Running Tests Faster and Running Faster Tests​.

What Happens When We Run the Test?

It fails. We haven’t written any code yet.

That’s Funny. What Really Happens—Internally?

When you run rspec with no arguments, RSpec loads every file in the spec directory. The following things happen (this process is slightly ...

Get Rails 4 Test Prescriptions 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.