From the course: Ruby: Testing with RSpec

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Helper methods

Helper methods - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Helper methods

- In this chapter, we'll learn about some tools and techniques that will make testing more efficient. And the first technique is the use of Helper Methods. You'll recall when we first initialized our project using rspec --init, that it actually did two things. It created a file for us, and at the root of our project, which is called .rspec, and it created a new file in our Spec Directory called spec_helper.rb. Let's take a look at the contents of that .rspec file. I can do that using Unix's cat command. The first line is a configuration that tells RSpec to do the output in color. The second one says --require spec_helper. What that does, is every time we run any specs with RSpec, it will automatically require our spec_helper file. That's great, makes it available to us all the time no matter what. This didn't use to be the case. You didn't use to be able to specify it from the RSpec file. The more old school way to do it, which I think you should still know about, is to just require…

Contents