avoid messing with finalize cycle in Disposable.

ensure statements are closed when connection is closed
This commit is contained in:
Brian J. Cardiff 2016-06-23 22:07:59 -03:00
parent f836bbfccb
commit 34ae9d5775
4 changed files with 39 additions and 5 deletions

View file

@ -1,5 +1,8 @@
require "./spec_helper"
class DummyException < Exception
end
describe DB::ResultSet do
it "should enumerate records using each" do
nums = [] of Int32
@ -15,4 +18,28 @@ describe DB::ResultSet do
nums.should eq([3, 4, 1, 2])
end
it "should close ResultSet after query" do
with_dummy do |db|
the_rs = uninitialized DB::ResultSet
db.query "3,4 1,2" do |rs|
the_rs = rs
end
the_rs.closed?.should be_true
end
end
it "should close ResultSet after query even with exception" do
with_dummy do |db|
the_rs = uninitialized DB::ResultSet
begin
db.query "3,4 1,2" do |rs|
the_rs = rs
raise DummyException.new
end
rescue DummyException
end
the_rs.closed?.should be_true
end
end
end