From 6a0a73ca7674cf0519b1a9d81aee3f0dc8ead880 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 6 Jan 2020 23:05:31 -0700 Subject: [PATCH] Add RSpec `match` matcher spec --- spec/rspec/expectations/match_matcher_spec.cr | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/rspec/expectations/match_matcher_spec.cr diff --git a/spec/rspec/expectations/match_matcher_spec.cr b/spec/rspec/expectations/match_matcher_spec.cr new file mode 100644 index 0000000..28b4f72 --- /dev/null +++ b/spec/rspec/expectations/match_matcher_spec.cr @@ -0,0 +1,30 @@ +require "../../spec_helper" + +# Examples taken from: +# https://relishapp.com/rspec/rspec-expectations/v/3-8/docs/built-in-matchers/match-matcher +# and modified to fit Spectator and Crystal. +Spectator.describe "`match` matcher" do + context "string usage" do + describe "a string" do + it { is_expected.to match(/str/) } + it { is_expected.not_to match(/foo/) } + + # deliberate failures + # TODO: Add support for expected failures. + xit { is_expected.not_to match(/str/) } + xit { is_expected.to match(/foo/) } + end + end + + context "regular expression usage" do + describe /foo/ do + it { is_expected.to match("food") } + it { is_expected.not_to match("drinks") } + + # deliberate failures + # TODO: Add support for expected failures. + xit { is_expected.not_to match("food") } + xit { is_expected.to match("drinks") } + end + end +end