spec/tries/tries_spec.rb in tries-0.0.2 vs spec/tries/tries_spec.rb in tries-0.1.0

- old
+ new

@@ -1,10 +1,10 @@ require 'spec_helper' describe Tries do before do - @counter = 0 + @error_counter = 0 end context 'when retrying on all errors' do it 'retries at least the defined number of times' do expect do @@ -56,18 +56,33 @@ raise_foo_foo_bar_bar_standard end end.to raise_error(BarError) end end + + context 'when specifying a delay' do + let(:delay) { 1.1 } + + it 'sleeps the specified delay' do + Kernel.should_receive(:sleep).with(delay).exactly(2).times + + begin + 3.tries on: FooError, delay: delay do + raise_foo_foo_bar_bar_standard + end + rescue StandardError + end + end + end end FooError = Class.new(StandardError) BarError = Class.new(StandardError) def raise_foo_foo_bar_bar_standard - @counter += 1 + @error_counter += 1 - case @counter + case @error_counter when 1 raise FooError when 2 raise FooError when 3