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

Numeric comparison matchers - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

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…

Contents