2016-01-29 19:15:28 +00:00
|
|
|
require "./spec_helper"
|
|
|
|
|
2016-02-04 00:29:19 +00:00
|
|
|
def assert_filename(uri, filename)
|
|
|
|
SQLite3::Connection.filename(URI.parse(uri)).should eq(filename)
|
|
|
|
end
|
|
|
|
|
2016-01-29 19:15:28 +00:00
|
|
|
describe Driver do
|
|
|
|
it "should register sqlite3 name" do
|
|
|
|
DB.driver_class("sqlite3").should eq(SQLite3::Driver)
|
|
|
|
end
|
|
|
|
|
2016-02-04 00:29:19 +00:00
|
|
|
it "should get filename from uri" do
|
|
|
|
assert_filename("sqlite3:%3Amemory%3A", ":memory:")
|
|
|
|
assert_filename("sqlite3://%3Amemory%3A", ":memory:")
|
|
|
|
|
|
|
|
assert_filename("sqlite3:./file.db", "./file.db")
|
|
|
|
assert_filename("sqlite3://./file.db", "./file.db")
|
|
|
|
|
|
|
|
assert_filename("sqlite3:/path/to/file.db", "/path/to/file.db")
|
|
|
|
assert_filename("sqlite3:///path/to/file.db", "/path/to/file.db")
|
2019-04-18 18:58:02 +00:00
|
|
|
|
2019-06-06 15:36:16 +00:00
|
|
|
assert_filename("sqlite3:./file.db?max_pool_size=5", "./file.db")
|
2019-04-18 18:58:02 +00:00
|
|
|
assert_filename("sqlite3:/path/to/file.db?max_pool_size=5", "/path/to/file.db")
|
|
|
|
assert_filename("sqlite3://./file.db?max_pool_size=5", "./file.db")
|
|
|
|
assert_filename("sqlite3:///path/to/file.db?max_pool_size=5", "/path/to/file.db")
|
2016-02-04 00:29:19 +00:00
|
|
|
end
|
|
|
|
|
2016-01-29 19:15:28 +00:00
|
|
|
it "should use database option as file to open" do
|
|
|
|
with_db do |db|
|
2016-02-04 00:29:19 +00:00
|
|
|
db.driver.should be_a(SQLite3::Driver)
|
2016-01-29 19:15:28 +00:00
|
|
|
File.exists?(DB_FILENAME).should be_true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|