diff --git a/src/spectator/dummy_example.cr b/src/spectator/dummy_example.cr new file mode 100644 index 0000000..6b6366a --- /dev/null +++ b/src/spectator/dummy_example.cr @@ -0,0 +1,22 @@ +require "./runnable_example" + +module Spectator + # Example 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 class DummyExample < RunnableExample + # Dummy description. + def what + "DUMMY" + end + + # Dummy run that does nothing. + def run_instance + # ... + end + end +end diff --git a/src/spectator/includes.cr b/src/spectator/includes.cr index 7bcd89d..3564ef1 100644 --- a/src/spectator/includes.cr +++ b/src/spectator/includes.cr @@ -16,6 +16,7 @@ require "./example_component" require "./example" require "./runnable_example" require "./pending_example" +require "./dummy_example" require "./example_hooks" require "./example_group" diff --git a/src/spectator/runnable_example.cr b/src/spectator/runnable_example.cr index 16009ed..d775d87 100644 --- a/src/spectator/runnable_example.cr +++ b/src/spectator/runnable_example.cr @@ -4,7 +4,7 @@ module Spectator # Common base for all examples that can be run. # This class includes all the logic for running example hooks, # the example code, and capturing a result. - # Sub-classes need to implement the `#run_instance` method. + # Sub-classes need to implement the `#what` and `#run_instance` methods. abstract class RunnableExample < Example # Runs the example, hooks, and captures the result # and translates to a usable result.