From 5987574a0ea79c9c7b0494273df6be3ccf997c66 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 5 Jan 2020 00:42:15 -0700 Subject: [PATCH] Add RSpec `be_within` matcher spec --- .../expectations/be_within_matcher_spec.cr | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 spec/rspec/expectations/be_within_matcher_spec.cr diff --git a/spec/rspec/expectations/be_within_matcher_spec.cr b/spec/rspec/expectations/be_within_matcher_spec.cr new file mode 100644 index 0000000..0307d1b --- /dev/null +++ b/spec/rspec/expectations/be_within_matcher_spec.cr @@ -0,0 +1,25 @@ +require "../../spec_helper" + +# Examples taken from: +# https://relishapp.com/rspec/rspec-expectations/v/3-8/docs/built-in-matchers/be-within-matcher +# and modified to fit Spectator and Crystal. +Spectator.describe "`be_within` matcher" do + context "basic usage" do + describe 27.5 do + it { is_expected.to be_within(0.5).of(27.9) } + it { is_expected.to be_within(0.5).of(28.0) } + it { is_expected.to be_within(0.5).of(27.1) } + it { is_expected.to be_within(0.5).of(27.0) } + + it { is_expected.not_to be_within(0.5).of(28.1) } + it { is_expected.not_to be_within(0.5).of(26.9) } + + # deliberate failures + # TODO: Add support for expected failures. + xit { is_expected.not_to be_within(0.5).of(28) } + xit { is_expected.not_to be_within(0.5).of(27) } + xit { is_expected.to be_within(0.5).of(28.1) } + xit { is_expected.to be_within(0.5).of(26.9) } + end + end +end