mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Test and improve "Anything"
This commit is contained in:
parent
4e3cb5d25f
commit
a20f2d4f98
2 changed files with 70 additions and 0 deletions
|
@ -1,15 +1,36 @@
|
|||
module Spectator
|
||||
# Type dedicated to matching everything.
|
||||
# This is intended to be used as a value to compare against when the value doesn't matter.
|
||||
# Can be used like so:
|
||||
# ```
|
||||
# anything = Spectator::Anything.new
|
||||
# array = ["foo", anything]
|
||||
# expect(["foo", "bar"]).to eq(array)
|
||||
# ```
|
||||
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"
|
||||
end
|
||||
|
||||
# Displays "<anything>".
|
||||
def inspect(io)
|
||||
io << "<anything>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue