Sha256: f7dd0f152e32467cf51fc560144f87f7eab57bafcddc241910319a34fcddfaae

Contents?: true

Size: 660 Bytes

Versions: 3

Compression:

Stored size: 660 Bytes

Contents

require 'helper'

class TestThread < MiniTest::Unit::TestCase

  def setup
    @manager = OpenStruct.new(queue: OpenStruct.new)
  end

  def test_initialized
    thread = Sideband::Thread.new(@manager)
    assert_kind_of ::Thread, thread.thread
  end

  def test_killed
    thread = Sideband::Thread.new(@manager)
    thread.kill
    sleep 0.1
    refute thread.thread.alive?
  end

  def test_joined
    work = 'work'
    @manager.queue = Queue.new
    @manager.queue << -> { work = 'finished' }
    @manager.queue << nil
    thread = Sideband::Thread.new(@manager)

    thread.join
    refute thread.thread.alive?
    assert_equal 'finished', work
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sideband-1.0.2 test/test_thread.rb
sideband-1.0.1 test/test_thread.rb
sideband-1.0.0 test/test_thread.rb