mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Change Anything to only use case equality
This commit is contained in:
parent
f46856f307
commit
7a5f7adfc2
2 changed files with 1 additions and 37 deletions
|
@ -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 }
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue