spec/index_spec.rb in digger-0.1.8 vs spec/index_spec.rb in digger-0.1.9
- old
+ new
@@ -7,6 +7,22 @@
sleep(rand(1..3))
"##{num}"
end
expect(pt.join).to eq(list.map { |num| "##{num}" }.join)
end
+
+ it 'slow down' do
+ list = [1, 2, 3, 4]
+ conf = {
+ sleep_range_seconds: 1...2,
+ fail_unit_seconds: 1,
+ fail_max_cnt: 2,
+ when_fail: ->(_, e, nth) { puts "#{nth}: #{e.message}" }
+ }
+ pt = Digger::Index.slow_down(list, conf) do |num|
+ raise 'error' if num == 3
+ num
+ end
+ p pt
+ expect(pt.size).to eq(2)
+ end
end