Sha256: 9663a154e0cf3d1348ead3b25a40d61227bda6ee96bdef6d4dfe4d634245a47c

Contents?: true

Size: 715 Bytes

Versions: 4

Compression:

Stored size: 715 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 => 1234567)
    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

4 entries across 4 versions & 1 rubygems

Version Path
ohm-0.0.18 test/connection_test.rb
ohm-0.0.17 test/connection_test.rb
ohm-0.0.15 test/connection_test.rb
ohm-0.0.16 test/connection_test.rb