From 0cb77b335506bfff979b19da6488fa9be2efe89a Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 12 Aug 2019 14:07:13 -0600 Subject: [PATCH] Add all-matcher to DSL --- src/spectator/dsl/matcher_dsl.cr | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/spectator/dsl/matcher_dsl.cr b/src/spectator/dsl/matcher_dsl.cr index 043ece4..bcfbec1 100644 --- a/src/spectator/dsl/matcher_dsl.cr +++ b/src/spectator/dsl/matcher_dsl.cr @@ -526,6 +526,19 @@ module Spectator::DSL ::Spectator::Matchers::AttributesMatcher.new(%test_value) end + # Verifies that all elements of a collection satisfy some matcher. + # The collection should implement `Enumerable`. + # + # Examples: + # ``` + # array = [1, 2, 3, 4] + # expect(array).to all(be_even) # Fails. + # expect(array).to all(be_lt(5)) # Passes. + # ``` + macro all(matcher) + ::Spectator::Matchers::AllMatcher.new({{matcher}}) + end + # Indicates that some expression's value should change after taking an action. # # Examples: