From 4056859deb29a3c235741996991e7e5549cca50f Mon Sep 17 00:00:00 2001 From: pedrinlopes Date: Tue, 30 Jul 2024 22:11:21 -0300 Subject: [PATCH] Rspec for SkipTask --- .../uber_task/task_skipped_on_error_spec.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 spec/non_rails/uber_task/task_skipped_on_error_spec.rb diff --git a/spec/non_rails/uber_task/task_skipped_on_error_spec.rb b/spec/non_rails/uber_task/task_skipped_on_error_spec.rb new file mode 100644 index 0000000..4d9a525 --- /dev/null +++ b/spec/non_rails/uber_task/task_skipped_on_error_spec.rb @@ -0,0 +1,20 @@ +describe UberTask::SkipTask do + it 'Skips the task on a error' do + task_skipped_after_exception = false + + UberTask.run do + UberTask.on_subtask_error do |_task, _event, err| + if err.message == 'Some error' + task_skipped_after_exception = true + UberTask.skip(reason: err) + end + end + + UberTask.run do + raise 'Some error' if task_skipped_after_exception == false + end + end + + expect(task_skipped_after_exception).to be(true) + end +end \ No newline at end of file