From 0fc28241ddda06bf170ccbd5b495e7e36cd9c97c Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 14 May 2019 21:50:09 -0600 Subject: [PATCH] Add be_between matcher which is an alias of be_within --- src/spectator/dsl/matcher_dsl.cr | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/spectator/dsl/matcher_dsl.cr b/src/spectator/dsl/matcher_dsl.cr index def9910..2edca3b 100644 --- a/src/spectator/dsl/matcher_dsl.cr +++ b/src/spectator/dsl/matcher_dsl.cr @@ -284,6 +284,26 @@ module Spectator::DSL ) end + # Indicates that some value should be between a lower and upper-bound. + # + # Example: + # ``` + # expect(7).to be_between(1, 10) + # ``` + # + # Additionally, an "inclusive" or "exclusive" suffix can be added. + # These modify the upper-bound on the range being checked against. + # By default, the range is inclusive. + # + # Examples: + # ``` + # expect(days).to be_between(28, 31).inclusive # 28, 29, 30, or 31 + # expect(100).to be_between(97, 101).exclusive # 97, 98, 99, or 100 (not 101) + # ``` + macro be_between(min, max) + be_within({{min}}, {{max}}) + end + # Indicates that some value should be within a delta of an expected value. # # Example: