Sha256: 3ea0d941de10cb79aee740fd88ea84f1f141af1ca3f066b1892a5a5d96c3c929

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

require 'helper'

class TestSideband < MiniTest::Unit::TestCase

  def test_must_be_initialized_before_use
    assert_raises Sideband::NotInitializedError do
      Sideband.queue << -> { 'work' }
    end
  end

  def test_has_queue
    Sideband.initialize! do
      assert_kind_of Sideband::Queue, Sideband.queue
    end
  end

  def test_manager_stored_in_thread_current
    Sideband.initialize! do
      assert_kind_of Sideband::Manager, ::Thread.current['sideband.manager']
    end
  end

  def test_can_be_used_in_separate_threads
    work_a, work_b = 'work', 'work'
    Sideband.initialize! do
      Sideband.queue << -> { work_a = 'finished' }

      Thread.new {
        Sideband.initialize! do
          Sideband.queue << -> { work_b = 'finished' }
        end
      }.join
    end

    assert_equal 'finished', work_a
    assert_equal 'finished', work_b
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sideband-1.0.1 test/test_sideband.rb
sideband-1.0.0 test/test_sideband.rb