Sha256: 8aeb2e897a57f376144e11081f34001347420281ba3ef7a1a71e8f23dcb15b71
Contents?: true
Size: 831 Bytes
Versions: 29
Compression:
Stored size: 831 Bytes
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 "return the value of the block" do result = @klass.retryable { 7 } assert_equal 7, result end end
Version data entries
29 entries across 29 versions & 3 rubygems