Refactor database cleanups to take the same path for #close and ruby's garbage collection.

FossilOrigin-Name: a2a8d99136cfa9e98e75cc262b8f9aefa5ed576d7af804416b8c8c7f4d4f4bdb
This commit is contained in:
Mahlon E. Smith 2020-12-01 07:58:49 +00:00
parent 2b745bc756
commit 0093c49b91
2 changed files with 42 additions and 12 deletions

View file

@ -17,5 +17,25 @@ RSpec.describe( MDBX::Database ) do
expect( db.closed? ).to be_truthy
end
context 'an opened database' do
before( :each ) do
@db = described_class.open( TEST_DATABASE.to_s )
end
after( :each ) do
@db.close
end
it "fails if opened again within the same process" do
# This is a function of libmdbx internals, just testing
# here for behaviorals.
expect {
described_class.open( TEST_DATABASE.to_s )
}.
to raise_exception( MDBX::DatabaseError, /environment is already used/ )
end
end
end