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.
Complex expectations - Ruby Tutorial
From the course: Ruby: Testing with RSpec
Complex expectations
- Now we get to start having some fun with the matchers that we know, by mixing and matching them. We're going to look at two things, Compound Expectations and Composing Matchers. Compound Expectations are pretty simple. It's just the ability to use And and Or in our expectations. And requires that both expressions be true. Or requires that either one of the expressions be true. And and Or also have aliases with the Ampersand or the single Pipe. Let me give you an example. Let's say that I have a string, Lynda, and I assign that to the variable S. I should expect S to Start With capital L dot And, and then End With lowercase A. See how that works. Both of those things should be true. It should start with L and end with A. Now you could actually handle this by writing two separate expectations. I expect S to start with L. I expect S to end with A. This just allows us to do it all in one. But Or, actually offers you something that you couldn't get by writing separate expectations. We…
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)
-
-
-
-
-
-
-