spec/tries/tries_spec.rb in tries-0.1.0 vs spec/tries/tries_spec.rb in tries-0.2.0
- old
+ new
@@ -70,27 +70,39 @@
raise_foo_foo_bar_bar_standard
end
rescue StandardError
end
end
+
+ context 'when setting incremental as true' do
+ let(:delay) { 1 }
+
+ it 'sleeps incrementally' do
+ Kernel.should_receive(:sleep).with(1).ordered
+ Kernel.should_receive(:sleep).with(2).ordered
+ Kernel.should_receive(:sleep).with(3).ordered
+
+ begin
+ 3.tries on: [FooError, BarError], delay: delay, incremental: true do
+ raise_foo_foo_bar_bar_standard
+ end
+ rescue StandardError
+ end
+ end
+ end
end
end
FooError = Class.new(StandardError)
BarError = Class.new(StandardError)
def raise_foo_foo_bar_bar_standard
@error_counter += 1
case @error_counter
- when 1
- raise FooError
- when 2
- raise FooError
- when 3
- raise BarError
- when 4
- raise BarError
- when 5
- raise StandardError
+ when 1 then raise FooError
+ when 2 then raise FooError
+ when 3 then raise BarError
+ when 4 then raise BarError
+ when 5 then raise StandardError
end
end