Sha256: 9608338259be6cc2a51709f4bae01f8cac5daf9a42096012828d68c3a55e92a9

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 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

2 entries across 2 versions & 1 rubygems

Version Path
ohm-0.0.20 test/connection_test.rb
ohm-0.0.19 test/connection_test.rb