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.
Numeric comparison matchers - Ruby Tutorial
From the course: Ruby: Testing with RSpec
Numeric comparison matchers
- We use numeric comparison matchers when we want to write expectations, which compare numeric values. The simplest one of these is equivalent, that two numeric values are equivalent to each other. And we already saw that in a previous movie. You'll remember that there were two ways that you can write it. We can use the eq matcher or we can use the be == matcher. The second way with the == is less common than the eq matcher, but it is instructive because many of the other comparison operators share this same syntax. So for example, we can expect 100 to be greater than 99. So the matcher is the be > matcher, even though there's a space between it. And in the same way, we can expect 100 to be less than 101. If we have >, <, we also have to have >= and <=. Together these will allow you to compare two values. Just remember that you have to have "be" in front of each of those operators. And that makes sense because it helps it to read as a proper sentence. In addition, we can use the…
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)
-
-
-
-
-
-
-