Sha256: af557b98fa87b3f8a80d16cc11d67900e1b078b681cb118e111d1a031869c232

Contents?: true

Size: 735 Bytes

Versions: 6

Compression:

Stored size: 735 Bytes

Contents

# encoding: UTF-8

require File.expand_path("./helper", File.dirname(__FILE__))

prepare.clear

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

  begin
    Ohm.redis.get "foo"
  rescue => e
    assert Errno::ECONNREFUSED == e.class
  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

test "supports connecting by URL" do
  Ohm.connect(:url => "redis://localhost:9876")

  begin
    Ohm.redis.get "foo"
  rescue => e
    assert Errno::ECONNREFUSED == e.class
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ohm-0.1.4 test/connection_test.rb
ohm-0.1.3 test/connection_test.rb
ohm-0.1.2 test/connection_test.rb
ohm-0.1.1 test/connection_test.rb
ohm-0.1.0 test/connection_test.rb
ohm-0.1.0.rc6 test/connection_test.rb