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 - Ruby Tutorial
From the course: Ruby: Testing with RSpec
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Fundamentals3m 48s
-
(Locked)
A deprecated modifier: should4m 19s
-
Equivalence matchers7m 3s
-
(Locked)
Truthiness matchers5m 41s
-
(Locked)
Numeric comparison matchers3m 32s
-
(Locked)
Collections6m 13s
-
(Locked)
Other useful matchers7m 44s
-
(Locked)
Predicate matchers5m 14s
-
(Locked)
Observation matchers10m 36s
-
(Locked)
Complex expectations10m 43s
-
(Locked)
-
-
-
-
-
-
-