test/connection_test.rb in ohm-0.1.0.rc5 vs test/connection_test.rb in ohm-0.1.0.rc6
- old
+ new
@@ -1,33 +1,45 @@
-require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
+# encoding: UTF-8
-class ConnectionTest < Test::Unit::TestCase
- test "connects lazily" do
- assert_nothing_raised do
- Ohm.connect(:port => 9876)
- end
+require File.expand_path("./helper", File.dirname(__FILE__))
- assert_raises(Errno::ECONNREFUSED) do
- Ohm.redis.get "foo"
- end
+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
+test "provides a separate connection for each thread" do
+ assert Ohm.redis == Ohm.redis
- conn1, conn2 = nil
+ conn1, conn2 = nil
- threads = []
+ threads = []
- threads << Thread.new do
- conn1 = Ohm.redis
- end
+ threads << Thread.new do
+ conn1 = Ohm.redis
+ end
- threads << Thread.new do
- conn2 = Ohm.redis
- end
+ threads << Thread.new do
+ conn2 = Ohm.redis
+ end
- threads.each { |t| t.join }
+ threads.each { |t| t.join }
- assert(conn1 != conn2)
+ 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