From 06230f128d2c9d6143f91419dcdc0da4d4c93f4a Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 27 Nov 2018 21:58:44 -0700 Subject: [PATCH] Add example for producing errors --- spec/helpers/errored_example.cr | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 spec/helpers/errored_example.cr diff --git a/spec/helpers/errored_example.cr b/spec/helpers/errored_example.cr new file mode 100644 index 0000000..369ad1f --- /dev/null +++ b/spec/helpers/errored_example.cr @@ -0,0 +1,22 @@ +# Example that always raises an exception. +class ErroredExample < Spectator::RunnableExample + # Dummy description. + def what + "ERROR" + end + + # Run the example that always produces an error. + private def run_instance + raise "Oops" + end + + # Creates an errored example. + def self.create + hooks = Spectator::ExampleHooks.empty + group = Spectator::RootExampleGroup.new(hooks) + values = Spectator::Internals::SampleValues.empty + new(group, values).tap do |example| + group.children = [example.as(Spectator::ExampleComponent)] + end + end +end