Sha256: a89c148059a82f9169e916ba09b7e88bc02d3eaa18903171ad1c41774ebfb68f

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 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(:selenium)
    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-0.2.0 test/unit/bbq_session_pool_test.rb
bbq-0.1.0 test/unit/bbq_session_pool_test.rb