Sha256: 1e5789489849145616b569d0a3c46731ad5a549e940df3a1884d746337a04ff8

Contents?: true

Size: 1.06 KB

Versions: 7

Compression:

Stored size: 1.06 KB

Contents

# encoding: UTF-8

require 'vines'
require 'minitest/autorun'

class SessionsTest < MiniTest::Unit::TestCase
  class MockSessions < Vines::Stream::Http::Sessions
    def start_timer
      # do nothing
    end
  end

  def setup
    @sessions = MockSessions.new
  end

  def test_session_add_and_delete
    session = MiniTest::Mock.new
    assert_nil @sessions['42']
    @sessions['42'] = session
    assert_equal session, @sessions['42']
    @sessions.delete('42')
    assert_nil @sessions['42']
  end

  def test_access_singleton_through_class_methods
    session = MiniTest::Mock.new
    assert_nil MockSessions['42']
    MockSessions['42'] = session
    assert_equal session, MockSessions['42']
    MockSessions.delete('42')
    assert_nil MockSessions['42']
  end

  def test_cleanup
    live = MiniTest::Mock.new
    live.expect(:expired?, false)

    dead = MiniTest::Mock.new
    dead.expect(:expired?, true)
    dead.expect(:close, nil)

    @sessions['live'] = live
    @sessions['dead'] = dead

    @sessions.send(:cleanup)
    assert live.verify
    assert dead.verify
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vines-0.4.0 test/stream/http/sessions_test.rb
vines-0.3.2 test/stream/http/sessions_test.rb
vines-0.3.1 test/stream/http/sessions_test.rb
vines-0.3.0 test/stream/http/sessions_test.rb
vines-0.2.1 test/stream/http/sessions_test.rb
vines-0.2.0 test/stream/http/sessions_test.rb
vines-0.1.1 test/stream/http/sessions_test.rb