Browse files

Add a test for timeout with a specified error type.

  • Loading branch information...
1 parent b2b70e3 commit 01c957aeac4ae0fcaf7b48063f8a8e4b6c35a97e @headius headius committed Jul 1, 2009
Showing with 9 additions and 1 deletion.
  1. +9 −1 library/timeout/timeout_spec.rb
View
10 library/timeout/timeout_spec.rb
@@ -2,13 +2,21 @@
require 'timeout'
describe "Timeout.timeout" do
- it "raises Timeout::Error when it times out" do
+ it "raises Timeout::Error when it times out with no specified error type" do
lambda {
Timeout::timeout(1) do
sleep 3
end
}.should raise_error(Timeout::Error)
end
+
+ it "raises specified error type when it times out" do
+ lambda do
+ Timeout.timeout(0.1, StandardError) do
+ sleep 1
+ end
+ end.should raise_error(StandardError)
+ end
it "does not wait too long" do
before_time = Time.now

0 comments on commit 01c957a

Please sign in to comment.