Running the Test

Having written your first test, you’d probably 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 details on those options, see Chapter 16, Running Tests Faster and Running Faster Tests.

What Happens When the Test Is Run?

It fails. You 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 simplified ...

Get Rails 5 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.