Skip to content

Commit

Permalink
Fix rubocop offenses (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzaakiirr authored Jul 4, 2024
1 parent 586308c commit 732c9ec
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 55 deletions.
1 change: 1 addition & 0 deletions lib/uber_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require 'logger'
require 'uber_task/internal'
require 'uber_task/internal/path'
Expand Down
8 changes: 4 additions & 4 deletions lib/uber_task/internal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
module UberTask
module Internal
def self.trace
if Thread.current[:__uber_task_trace__]
message = yield
puts message
end
return unless Thread.current[:__uber_task_trace__]

message = yield
puts message
end
end
end
47 changes: 24 additions & 23 deletions spec/exception_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
describe UberTask do
it 'Retries the child task after two exceptions' do
task_retried_after_exception = 0

UberTask.run do
UberTask.on_subtask_error do |task, event, err|
if err.message == 'Some error'
task_retried_after_exception += 1
UberTask.retry(reason: err, wait: 1)
end
end

UberTask.run(retry_count: 2, vital: false) do
if task_retried_after_exception < 2
raise 'Some error'
end
end
end


expect(task_retried_after_exception).to be(2)
end
end
# frozen_string_literal: true

describe UberTask do
it 'Retries the child task after two exceptions' do
task_retried_after_exception = 0

UberTask.run do
UberTask.on_subtask_error do |_task, _event, err|
if err.message == 'Some error'
task_retried_after_exception += 1
UberTask.retry(reason: err, wait: 1)
end
end

UberTask.run(retry_count: 2, vital: false) do
if task_retried_after_exception < 2
raise 'Some error'
end
end
end

expect(task_retried_after_exception).to be(2)
end
end
34 changes: 18 additions & 16 deletions spec/uber_task/run_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
describe UberTask do
describe '.run' do
it 'retries the task' do
run_count = 0

UberTask.run(retry_count: 3) do
if run_count < 2
run_count += 1
UberTask.retry(wait: 1)
end
end

expect(run_count).to be(2)
end
end
end
# frozen_string_literal: true

describe UberTask do
describe '.run' do
it 'retries the task' do
run_count = 0

UberTask.run(retry_count: 3) do
if run_count < 2
run_count += 1
UberTask.retry(wait: 1)
end
end

expect(run_count).to be(2)
end
end
end
26 changes: 14 additions & 12 deletions spec/uber_task/skip_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
describe UberTask do
it 'skips the task' do
task_skipped = true

UberTask.run do
UberTask.skip
task_skipped = false
end

expect(task_skipped).to be(true)
end
end
# frozen_string_literal: true

describe UberTask do
it 'skips the task' do
task_skipped = true

UberTask.run do
UberTask.skip
task_skipped = false
end

expect(task_skipped).to be(true)
end
end

0 comments on commit 732c9ec

Please sign in to comment.