shard-spectator/src/spectator/test_expression.cr

26 lines
635 B
Crystal
Raw Normal View History

2019-08-01 21:44:04 +00:00
module Spectator
# Base type for capturing an expression from a test.
abstract struct TestExpression(T)
2019-08-01 02:01:39 +00:00
# User-friendly string displayed for the actual expression being tested.
# For instance, in the expectation:
# ```
# expect(foo).to eq(bar)
# ```
# This property will be "foo".
# It will be the literal string "foo",
# and not the actual value of the foo.
getter label : String
# Creates the common base of the expression.
2019-08-01 02:01:39 +00:00
def initialize(@label)
end
abstract def value : T
# String representation of the expression.
2019-08-01 02:01:39 +00:00
def to_s(io)
io << label
end
end
end