Sha256: 840a8cda2174f77ec97f5d793962aeced4dcbe437f83e8c6d26922f00fd22638

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'test_helper'
require 'bbq/core/test_user'

class SessionPoolTest < Minitest::Test

  def setup
    Bbq::Core::Session.instance_variable_set(:@pool, nil)
  end

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

    assert_same user1.page, user2.page
  end

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

    assert_same user1.page, user2.page
  end

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

    refute_same user1.page, user2.page
  end

  def test_pool_returns_correct_driver
    pool = Bbq::Core::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

2 entries across 2 versions & 1 rubygems

Version Path
bbq-core-0.4.0 test/session_pool_test.rb
bbq-core-0.3.0 test/session_pool_test.rb