Sha256: cd0dda220936a9ad437d4277b313c6fab5b7315c16dc0c3dce6d2ba4860f6c5a

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

require 'assert'
require 'dat-worker-pool/worker'

require 'dat-worker-pool'
require 'dat-worker-pool/queue'

class DatWorkerPool::Worker

  class BaseTests < Assert::Context
    desc "DatWorkerPool::Worker"
    setup do
      @pool  = DatWorkerPool.new{ }
      @queue = DatWorkerPool::Queue.new
      @workers_waiting = DatWorkerPool::WorkersWaiting.new
      @worker = DatWorkerPool::Worker.new(@pool, @queue, @workers_waiting){ }
    end
    subject{ @worker }

    should have_imeths :shutdown, :join

    should "trigger exiting it's work loop with #shutdown and " \
           "join it's thread with #join" do
      @queue.shutdown   # ensure the thread is not waiting on the queue
      subject.join(0.1) # ensure the thread is looping for work
      subject.shutdown
      assert_not_nil subject.join(1)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dat-worker-pool-0.1.0 test/unit/worker_tests.rb