From 7277b3caaf9baeb19bbae60c1f56bf4a9d95179c Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 7 Oct 2018 12:49:10 -0600 Subject: [PATCH] Display actual value if label is empty --- src/spectator/expectations/value_expectation_partial.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/spectator/expectations/value_expectation_partial.cr b/src/spectator/expectations/value_expectation_partial.cr index 5955817..a9767d9 100644 --- a/src/spectator/expectations/value_expectation_partial.cr +++ b/src/spectator/expectations/value_expectation_partial.cr @@ -12,6 +12,12 @@ module Spectator::Expectations super(label) end + # Returns the actual value as a string + # if there's no label available. + def label + super.empty? ? actual.to_s : super + end + # Asserts that the `#actual` value matches some criteria. # The criteria is defined by the matcher passed to this method. def to(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType