From ae3fdc837bee21b5a9adb404508c8d421264fc63 Mon Sep 17 00:00:00 2001 From: pedrinlopes Date: Tue, 30 Jul 2024 22:08:27 -0300 Subject: [PATCH 1/3] Add ruby version --- .ruby-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .ruby-version 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 From 4056859deb29a3c235741996991e7e5549cca50f Mon Sep 17 00:00:00 2001 From: pedrinlopes Date: Tue, 30 Jul 2024 22:11:21 -0300 Subject: [PATCH 2/3] 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 From b2b38914e72ee60915afbeecb92239898c065d3a Mon Sep 17 00:00:00 2001 From: pedrinlopes Date: Tue, 30 Jul 2024 23:04:56 -0300 Subject: [PATCH 3/3] Fix cop rules --- spec/non_rails/uber_task/task_skipped_on_error_spec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 index 4d9a525..fd86895 100644 --- a/spec/non_rails/uber_task/task_skipped_on_error_spec.rb +++ b/spec/non_rails/uber_task/task_skipped_on_error_spec.rb @@ -1,7 +1,9 @@ +# 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' @@ -10,11 +12,11 @@ end end - UberTask.run do + 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 +end