Make Example comparable against names and sources

This will be needed for filtering examples.
This commit is contained in:
Michael Miller 2019-03-23 21:40:13 -06:00
parent 4f3ca20741
commit 2f8b4761de
3 changed files with 140 additions and 0 deletions

View file

@ -59,5 +59,21 @@ module Spectator
def to_json(json : ::JSON::Builder)
json.string(to_s)
end
# Checks if this example matches some criteria.
# This is used to filter examples.
def ===(other)
other === to_s
end
# Checks if this example is at the specified source.
def ===(other : Source)
source == other
end
# Checks if this example is at the specified line number.
def ===(other : Int32)
source.line === other
end
end
end