spec/connection_pool_spec.rb in stillwater-0.0.2 vs spec/connection_pool_spec.rb in stillwater-0.0.3
- old
+ new
@@ -70,22 +70,26 @@
end
describe "#retry_connection_from" do
before(:each) do
subject.add { TestConnection.new("two") }
+ subject.add { TestConnection.new("three") }
end
it "should retry a connection when receiving specific exception type" do
client_obj = mock("ClientObject")
- client_obj.stubs(:do_something).raises(TestException).then.returns("client result")
+ client_obj.stubs(:do_something).
+ raises(TestException).then.
+ raises(TestException).then.
+ returns("client result")
result = subject.retry_connection_from(TestException) do |conn|
client_obj.do_something
end
subject.available_count.should == 1
- subject.inactive_count.should == 1
+ subject.inactive_count.should == 2
result.should == "client result"
end
it "should respect the retry limit" do
subject.retry_count = 1
@@ -94,11 +98,11 @@
subject.retry_connection_from(TestException) do |conn|
raise TestException
end
}.should raise_error(TestException)
- subject.available_count.should == 1
+ subject.available_count.should == 2
subject.inactive_count.should == 1
end
it "should fail if all connections get deactivated" do
lambda {
@@ -162,9 +166,11 @@
subject.deactivate conn1
subject.deactivate conn2
sleep 2
+ conn = subject.checkout
+ subject.checkin conn
subject.available_count.should == 3
subject.inactive_count.should == 0
end
end
end