Sha256: 1d14b40f90b5bf4fc8cefd0c6dcd8750d1fc7e695f311171a2f8e48dcd681e35
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true require 'spec_helper' RSpec.describe ExpRetry do it 'should allow normal execution' do r = ExpRetry.new.call do 'Something' end expect(r).to eql('Something') end it 'should allow normal execution with a single failure' do @fail_once = true r = ExpRetry.new.call do if @fail_once @fail_once = false raise 'Fail once' end 'Something' end expect(r).to eql('Something') end it 'should allow normal execution with multiple exceptions' do @fail_once = true r = ExpRetry.new(exception: [RuntimeError, ArgumentError]).call do if @fail_once @fail_once = false raise 'Fail once again' end 'Something' end expect(r).to eql('Something') end it 'should raise after too many retries' do expect do ExpRetry.new.call { raise 'Fail forever' } end.to raise_error(RuntimeError, 'Fail forever') end it 'should raise after too many retries with a specified exception class' do expect do ExpRetry.new(exception: RuntimeError).call { raise 'Fail forever again' } end.to raise_error(RuntimeError, 'Fail forever again') end it 'should not retry for a non-matching exception class' do expect do ExpRetry.new(exception: RuntimeError).call { raise ArgumentError } end.to raise_error(ArgumentError) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
exp_retry-0.0.7 | spec/lib/exp_retry_spec.rb |
exp_retry-0.0.6 | spec/lib/exp_retry_spec.rb |