Sha256: 0e97ffefa713cd9dea551cf5be9bcc20a6d6f54d36f82ba4e94f9c651048409f

Contents?: true

Size: 708 Bytes

Versions: 20

Compression:

Stored size: 708 Bytes

Contents

require File.join(File.dirname(__FILE__), "test_helper")

class ConnectionTest < Test::Unit::TestCase
  setup do
    @options = Ohm.options
  end

  test "connects lazily" do
    assert_nothing_raised do
      Ohm.connect(:port => 9876)
    end

    assert_raises(Errno::ECONNREFUSED) do
      Ohm.redis.get "foo"
    end
  end

  test "provides a separate connection for each thread" do
    assert Ohm.redis == Ohm.redis

    conn1, conn2 = nil

    threads = []

    threads << Thread.new do
      conn1 = Ohm.redis
    end

    threads << Thread.new do
      conn2 = Ohm.redis
    end

    threads.each { |t| t.join }

    assert (conn1 != conn2)
  end

  teardown do
    Ohm.connect(*@options)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ohm-0.0.38 test/connection_test.rb
ohm-0.0.37 test/connection_test.rb
ohm-0.0.36 test/connection_test.rb
ohm-0.1.0.rc2 test/connection_test.rb
ohm-0.1.0.rc1 test/connection_test.rb
ohm-0.0.35 test/connection_test.rb
ohm-0.0.34 test/connection_test.rb
ohm-0.0.33 test/connection_test.rb
ohm-0.0.32 test/connection_test.rb
ohm-0.0.31 test/connection_test.rb
ohm-0.0.30 test/connection_test.rb
ohm-0.0.29 test/connection_test.rb
ohm-0.0.28 test/connection_test.rb
ohm-0.0.27 test/connection_test.rb
ohm-0.0.26 test/connection_test.rb
ohm-0.0.25 test/connection_test.rb
ohm-0.0.24 test/connection_test.rb
ohm-0.0.23 test/connection_test.rb
ohm-0.0.22 test/connection_test.rb
ohm-0.0.21 test/connection_test.rb