spec/db_spec.rb in knjrbfw-0.0.27 vs spec/db_spec.rb in knjrbfw-0.0.28
- old
+ new
@@ -5,14 +5,15 @@
describe "Db" do
it "should be able to handle various encodings" do
#I never got this test to actually fail... :-(
require "knj/db"
- require "tmpdir"
- require "sqlite3"
+ require "knj/os"
+ require "sqlite3" if !Kernel.const_defined?("SQLite3")
- db_path = "#{Dir.tmpdir}/knjrbfw_test_sqlite3.sqlite3"
+ db_path = "#{Knj::Os.tmpdir}/knjrbfw_test_sqlite3.sqlite3"
+ File.unlink(db_path) if File.exists?(db_path)
db = Knj::Db.new(
:type => "sqlite3",
:path => db_path,
:return_keys => "symbols",
@@ -23,9 +24,29 @@
"columns" => [
{"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
{"name" => "text", "type" => "varchar"}
]
})
+
+ schema = {
+ "tables" => {
+ "test_table" => {
+ "columns" => [
+ {"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
+ {"name" => "name", "type" => "varchar"}
+ ],
+ "rows" => [
+ {
+ "find_by" => {"id" => 1},
+ "data" => {"id" => 1, "name" => "trala"}
+ }
+ ]
+ }
+ }
+ }
+
+ rev = Knj::Db::Revision.new
+ rev.init_db("schema" => schema, "db" => db)
begin
cont = File.read("#{File.dirname(__FILE__)}/db_spec_encoding_test_file.txt")
cont.force_encoding("ASCII-8BIT")
\ No newline at end of file