From 20d8cb0c25fa864742e92af698494bffcd8e0f53 Mon Sep 17 00:00:00 2001 From: pedrinlopes <143508172+pedrinlopes@users.noreply.github.com> Date: Tue, 30 Jul 2024 23:08:02 -0300 Subject: [PATCH] Increase code coverage (#23) --- .ruby-version | 1 + .../uber_task/task_skipped_on_error_spec.rb | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 .ruby-version create mode 100644 spec/non_rails/uber_task/task_skipped_on_error_spec.rb diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..a0891f5 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.3.4 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..fd86895 --- /dev/null +++ b/spec/non_rails/uber_task/task_skipped_on_error_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +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