Skip to content

Commit

Permalink
chore: test with ensure
Browse files Browse the repository at this point in the history
  • Loading branch information
bobstrange committed Sep 10, 2023
1 parent 1910ebf commit 6596a7e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ruby/retryable/main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,24 @@ def test_error
end
end

def test_error_with_ensure
ensure_callback = lambda do |retries|
Logger.new(STDOUT).info("total attempts: #{retries}")
end

error = assert_raises RuntimeError do
Retryable.retryable(
on: StandardError,
sleep: 0.1,
tries: 3,
log_method: log_method,
ensure: ensure_callback
) do
raise_error
end
end

# Even though we put ensure block, the error will be thrown if retries exhausted
assert_equal("100% error", error.message)
end
end

0 comments on commit 6596a7e

Please sign in to comment.