spec/exception_spec.rb in rufus-scheduler-2.0.11 vs spec/exception_spec.rb in rufus-scheduler-2.0.12
- old
+ new
@@ -3,11 +3,11 @@
# Specifying rufus-scheduler
#
# Mon May 4 17:07:17 JST 2009
#
-require File.join(File.dirname(__FILE__), '/spec_base')
+require 'spec_base'
describe SCHEDULER_CLASS do
before(:each) do
@@ -15,25 +15,25 @@
end
after(:each) do
stop_scheduler(@s)
end
- it 'emits exception messages to stdout' do
+ it 'emits exception messages to stderr' do
require 'stringio' unless defined?(StringIO) # ruby 1.9
- stdout = $stdout
+ stderr = $stderr
s = StringIO.new
- $stdout = s
+ $stderr = s
@s.in 0.400 do
raise 'Houston we have a problem'
end
sleep 0.500
sleep 0.500
- $stdout = stdout
+ $stderr = stderr
s.close
s.string.should match(/Houston we have a problem/)
end
@@ -53,11 +53,11 @@
sleep 0.500
$job.class.should == Rufus::Scheduler::InJob
end
- it 'accepts overriding #log_exception' do
+ it 'accepts defining #log_exception' do
$e = nil
def @s.log_exception(e)
$e = e
@@ -68,9 +68,30 @@
end
sleep 0.500
sleep 0.500
+ $e.to_s.should == 'Houston we have a problem'
+ end
+
+ it 'accepts defining #on_exception' do
+
+ $j = nil
+ $e = nil
+
+ def @s.on_exception(j, e)
+ $j = j
+ $e = e
+ end
+
+ @s.in 0.400 do
+ raise 'Houston we have a problem'
+ end
+
+ sleep 0.500
+ sleep 0.500
+
+ $j.class.should == Rufus::Scheduler::InJob
$e.to_s.should == 'Houston we have a problem'
end
end