2019-12-08 21:52:28 +00:00
|
|
|
module Spectator
|
2021-02-10 02:10:11 +00:00
|
|
|
# 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
|
2021-02-10 04:18:20 +00:00
|
|
|
# expect("foo").to match(anything)
|
2021-02-10 02:10:11 +00:00
|
|
|
# ```
|
2019-12-08 21:52:28 +00:00
|
|
|
struct Anything
|
2021-02-10 02:10:11 +00:00
|
|
|
# Always returns true.
|
2019-12-08 21:52:28 +00:00
|
|
|
def ===(other)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2021-02-10 02:10:11 +00:00
|
|
|
# Displays "anything".
|
|
|
|
def to_s(io)
|
|
|
|
io << "anything"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Displays "<anything>".
|
|
|
|
def inspect(io)
|
|
|
|
io << "<anything>"
|
|
|
|
end
|
2019-12-08 21:52:28 +00:00
|
|
|
end
|
|
|
|
end
|