From 429c2d730215fc755dd252e9adaac542362cc903 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Wed, 23 Jan 2019 15:35:32 -0700 Subject: [PATCH] Add #be_true and #be_false to DSL --- src/spectator/dsl/matcher_dsl.cr | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/spectator/dsl/matcher_dsl.cr b/src/spectator/dsl/matcher_dsl.cr index 411e611..c04dd64 100644 --- a/src/spectator/dsl/matcher_dsl.cr +++ b/src/spectator/dsl/matcher_dsl.cr @@ -57,5 +57,27 @@ module Spectator::DSL macro match(expected) ::Spectator::Matchers::RegexMatcher.new({{expected.stringify}}, {{expected}}) end + + # Indicates that some value should be true. + # + # Examples: + # ``` + # expect(nil.nil?).to be_true + # expect(%i[a b c].any?).to be_true + # ``` + macro be_true + eq(true) + end + + # Indicates that some value should be false. + # + # Examples: + # ``` + # expect("foo".nil?).to be_false + # expect(%i[a b c].empty?).to be_false + # ``` + macro be_false + eq(false) + end end end