Sha256: ad5708b3df6e9029d8b836acc88aff3c7520150b3234430bdaff004c22e88383

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'helper'

class TestManager < MiniTest::Unit::TestCase

  def setup
    @manager = Sideband::Manager.new
  end

  def test_has_queue
    assert_kind_of Sideband::Queue, @manager.queue
  end

  def test_has_thread
    assert_kind_of Sideband::Thread, @manager.thread
  end

  def test_can_queue_and_process_proc
    work = 'work'
    @manager.queue << -> { work = 'finished' }
    sleep 0.1
    assert_equal 'finished', work 
  end

  def test_can_queue_and_process_worker
    worker = EmailWorker.new
    assert_equal 'work', worker.work
    @manager.queue << worker
    sleep 0.1
    assert_equal 'finished', worker.work 
  end

  if !jruby?
    def test_fork_handling
      puts RUBY_PLATFORM
      queue  = @manager.queue
      thread = @manager.thread
  
      Process.stub(:pid, Process.pid + 1) do
        @manager.queue << -> { 'work' }
        refute_equal queue,  @manager.queue
        refute_equal thread, @manager.thread
      end
  end
end

  def test_killed
    @manager.kill
    assert_nil @manager.queue
    assert_nil @manager.thread
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sideband-1.0.1 test/test_manager.rb