From the course: Ruby: Testing with RSpec

Unlock the full course today

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

Helper specs

Helper specs - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Helper specs

- In this movie, I'll give you some advice on writing Specs for the Helpers in a Rails application. Working with Rails Helpers is almost as easy as working with models. We can work with them in isolation and there's no request response cycle for us to worry about. There is one important feature you need to know about though. There's a special object called Helper that we can make use of in our examples. Let's say that I have a method defined in my ApplicationHelper called "#inch_to_cm" or inches to centimeters. So we're going to convert a number to centimeters by multiplying it by 2.54. In my example for that, I have expect and then you'll see that I have helper.inch_to_cm. I'm calling inch_to_cm on that special Helper object. Remember that Helpers are Ruby modules, not Ruby classes. We could have included the module in our Spec file and then we'd have access to all of it's methods but using the Helper object instead has two advantages. The first is that the Helper object also…

Contents