From the course: Ruby: Testing with RSpec
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Collections
- In this movie, we'll take a look at RSpec's Collection Matchers. Now, what do I mean by a collection? Really what we're talking about are arrays, hashes or strings. Strings are collection of letters. They work in a lot of ways very similar to an array, right? We have different order of letters, just like we have different order of elements inside an array. Those are the three things we're going to be looking at with Collection Matchers. Let's start with arrays. Let's say I have a simple array, [1,2,3]. I can use the include matcher to assert that a value should be included in that array so I can expect the array to include 3 or I can provide more than one value. The order doesn't matter here. What I'm actually making are two different expectations. I'm expecting the array to include 2, and I'm expecting the array to include 3. I'm writing two arguments, both of them need to be true. I can use the start_with or end_with matchers to make an assertion about the values that the array…
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)
-
-
-
-
-
-
-