Sha256: 00cabaa194b3452c0fbe6da4a3433854f6dd460390b4b220ecc82607c4d90337

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'test_helper'
require 'bbq/test_user'

class BbqSessionPoolTest < Test::Unit::TestCase
  def setup
    Bbq::Session.instance_variable_set(:@pool, nil)
  end

  def test_reuses_sessions
    pool = Bbq::Session::Pool.new
    user1 = Bbq::TestUser.new(:pool => pool).tap { |u| u.page }
    pool.release
    user2 = Bbq::TestUser.new(:pool => pool).tap { |u| u.page }

    assert_same user1.page, user2.page
  end

  def test_has_default_pool
    user1 = Bbq::TestUser.new.tap { |u| u.page }
    Bbq::Session::pool.release
    user2 = Bbq::TestUser.new.tap { |u| u.page }

    assert_same user1.page, user2.page
  end

  def test_without_pool
    user1 = Bbq::TestUser.new(:pool => false).tap { |u| u.page }
    Bbq::Session::pool.release
    user2 = Bbq::TestUser.new(:pool => false).tap { |u| u.page }

    assert_not_same user1.page, user2.page
  end

  def test_pool_returns_correct_driver
    pool = Bbq::Session::Pool.new
    pool.next(:rack_test)
    pool.next(:rack_test_the_other)
    pool.release

    assert_equal :rack_test, pool.next(:rack_test).mode
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bbq-0.2.1 test/unit/bbq_session_pool_test.rb