Today I Learned Rspec Include Matchers
Landon Schropp •
You can use Rspec matchers inside of include to test multiple values in the hash.
banana = {
name: "banana",
type: "cavendish",
colors: ["yellow", "green"],
}
expect(banana).to include(
name: "banana",
type: match(/cav/),
colors: match_array(["green", "yellow"]),
)
The example above ensures the banana hash includes a :name key with a value of "banana", a :type that matches the regular expression /cav/ , and a :colors key that contains an array with the elements "green" and "yellow" in any order.