Sha256: b6d9f1d320edaa2c5f89652505f3d66dd04a11a5c54cf6272699f2af92ebace7
Contents?: true
Size: 1.09 KB
Versions: 32
Compression:
Stored size: 1.09 KB
Contents
require "test_helper" class RetryableUtilTest < Test::Unit::TestCase setup do @klass = Class.new do extend Vagrant::Util::Retryable end end should "retry specified number of times if exception is raised" do proc = mock("proc") proc.expects(:call).twice assert_raises(RuntimeError) { @klass.retryable(:tries => 2, :on => RuntimeError) do proc.call raise "An error" end } end should "only retry on specified exception" do proc = mock("proc") proc.expects(:call).once assert_raises(StandardError) { @klass.retryable(:tries => 5, :on => RuntimeError) do proc.call raise StandardError.new end } end should "retry on multiple exceptions given" do proc = mock("proc") proc.expects(:call).twice assert_raises(StandardError) { @klass.retryable(:tries => 2, :on => [StandardError, RuntimeError]) do proc.call raise StandardError end } end should "return the value of the block" do result = @klass.retryable { 7 } assert_equal 7, result end end
Version data entries
32 entries across 32 versions & 4 rubygems