Sha256: d78837fe97e30934cd95c0ee856c1952a487a6aea22ea5a964589c5cf325111a

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

#
# Specifying rufus-scheduler
#
# Mon May  4 17:07:17 JST 2009
#

require 'spec_base'


describe SCHEDULER_CLASS do

  before(:each) do
    @s = start_scheduler
  end
  after(:each) do
    stop_scheduler(@s)
  end

  it 'emits exception messages to stderr' do

    require 'stringio' unless defined?(StringIO) # ruby 1.9

    stderr = $stderr
    s = StringIO.new
    $stderr = s

    @s.in 0.400 do
      raise 'Houston we have a problem'
    end

    sleep 0.500
    sleep 0.500
    $stderr = stderr
    s.close

    s.string.should match(/Houston we have a problem/)
  end

  it 'accepts custom handling of exceptions' do

    $job = nil

    def @s.handle_exception(j, e)
      $job = j
    end

    @s.in 0.400 do
      raise 'Houston we have a problem'
    end

    sleep 0.500
    sleep 0.500

    $job.class.should == Rufus::Scheduler::InJob
  end

  it 'accepts defining #log_exception' do

    $e = nil

    def @s.log_exception(e)
      $e = e
    end

    @s.in 0.400 do
      raise 'Houston we have a problem'
    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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rufus-scheduler-2.0.19 spec/exception_spec.rb
rufus-scheduler-2.0.18 spec/exception_spec.rb
rufus-scheduler-2.0.17 spec/exception_spec.rb
rufus-scheduler-2.0.16 spec/exception_spec.rb
rufus-scheduler-2.0.15 spec/exception_spec.rb
rufus-scheduler-2.0.14 spec/exception_spec.rb
rufus-scheduler-2.0.13 spec/exception_spec.rb
rufus-scheduler-2.0.12 spec/exception_spec.rb