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.

A deprecated modifier: should

A deprecated modifier: should - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

A deprecated modifier: should

- In this movie I want us to take a moment before we dive into matchers to talk about a deprecated part of RSpec. It's a modifying method called "should". Deprecated means that it's a part of RSpec that's outdated, that we should not use, or might be removed soon. In RSpec version two there was a "should" syntax, and it was the main way that you defined your expectations. We've seen the newer RSpec three syntax where we have expect something to equal something. In RSpec two with the "should" syntax you would have @count.should equal three instead. You see how that works? We're calling "should" as a method direction on count, or we might should not equal. It's very readable, and you might actually prefer it over the newer "expect" syntax, but, unfortunately, it has some problems. Notice that we're calling "should" on count, but we don't know what count is. Count could be an array, a string, another kind of object that we've defined, and "should" has to be a method available for all of…

Contents