From 7a5f7adfc297fc3fc311025fda7b12a5f6d8aaf1 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 9 Feb 2021 21:18:20 -0700 Subject: [PATCH] Change Anything to only use case equality --- spec/spectator/anything_spec.cr | 25 ------------------------- src/spectator/anything.cr | 13 +------------ 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/spec/spectator/anything_spec.cr b/spec/spectator/anything_spec.cr index 11672a5..3140f7e 100644 --- a/spec/spectator/anything_spec.cr +++ b/spec/spectator/anything_spec.cr @@ -1,15 +1,6 @@ require "../spec_helper" Spectator.describe Spectator::Anything do - it "equals everything" do - expect(true).to eq(subject) - expect(false).to eq(subject) - expect(nil).to eq(subject) - expect(42).to eq(subject) - expect(42.as(Int32 | String)).to eq(subject) - expect(["foo", "bar"]).to eq(subject) - end - it "matches everything" do expect(true).to match(subject) expect(false).to match(subject) @@ -19,22 +10,6 @@ Spectator.describe Spectator::Anything do expect(["foo", "bar"]).to match(subject) end - context "nested in a container" do - it "equals everything" do - expect(["foo", "bar"]).to eq(["foo", subject]) - expect({"foo", "bar"}).to eq({"foo", subject}) - expect({foo: "bar"}).to eq({foo: subject}) - expect({"foo" => "bar"}).to eq({"foo" => subject}) - end - - it "matches everything" do - expect(["foo", "bar"]).to match(["foo", subject]) - expect({"foo", "bar"}).to match({"foo", subject}) - expect({foo: "bar"}).to match({foo: subject}) - expect({"foo" => "bar"}).to match({"foo" => subject}) - end - end - describe "#to_s" do subject { super.to_s } diff --git a/src/spectator/anything.cr b/src/spectator/anything.cr index 6dafc60..e4d7b34 100644 --- a/src/spectator/anything.cr +++ b/src/spectator/anything.cr @@ -4,25 +4,14 @@ module Spectator # Can be used like so: # ``` # anything = Spectator::Anything.new - # array = ["foo", anything] - # expect(["foo", "bar"]).to eq(array) + # expect("foo").to match(anything) # ``` struct Anything - # Always returns true. - def ==(other) - true - end - # Always returns true. def ===(other) true end - # Always returns true. - def =~(other) - true - end - # Displays "anything". def to_s(io) io << "anything"