From 165178237c9e2af53b6c0ab8f44fbca4310d34af Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 22 Mar 2019 13:34:44 -0600 Subject: [PATCH] Add dummy match data Apparently the abstract bug pops up again when there are no tests. --- src/spectator/matchers/dummy_match_data.cr | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/spectator/matchers/dummy_match_data.cr diff --git a/src/spectator/matchers/dummy_match_data.cr b/src/spectator/matchers/dummy_match_data.cr new file mode 100644 index 0000000..175cf53 --- /dev/null +++ b/src/spectator/matchers/dummy_match_data.cr @@ -0,0 +1,32 @@ +module Spectator::Matchers + # Match data that does nothing. + # This is to workaround a Crystal compiler bug. + # See: [Issue 4225](https://github.com/crystal-lang/crystal/issues/4225) + # If there are no concrete implementations of an abstract class, + # the compiler gives an error. + # The error indicates an abstract method is undefined. + # This class shouldn't be used, it's just to trick the compiler. + private struct DummyMatchData < MatchData + # Creates the match data. + def initialize + super(false) + end + + # Dummy values. + def named_tuple + { + you: "shouldn't be calling this." + } + end + + # Dummy message. + def message + "You shouldn't be calling this." + end + + # Dummy message + def negated_message + "You shouldn't be calling this." + end + end +end