shard-crystal-sqlite3/spec/driver_spec.cr
Brian J. Cardiff 5eb85a98c6 Update to crystal-db ~> 0.4.1
Replace driver_spec for db/spec.
Fix read(T?) for T = Int32, Flaot32, Time, Bool..
Fixes #19
2017-04-10 14:09:22 -03:00

29 lines
848 B
Crystal

require "./spec_helper"
def assert_filename(uri, filename)
SQLite3::Connection.filename(URI.parse(uri)).should eq(filename)
end
describe Driver do
it "should register sqlite3 name" do
DB.driver_class("sqlite3").should eq(SQLite3::Driver)
end
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")
end
it "should use database option as file to open" do
with_db do |db|
db.driver.should be_a(SQLite3::Driver)
File.exists?(DB_FILENAME).should be_true
end
end
end