spec/support/driver_tables_collection.rb in baza-0.0.20 vs spec/support/driver_tables_collection.rb in baza-0.0.21

- old
+ new

@@ -2,14 +2,17 @@ let(:driver) { constant.new } let(:driver2) { constant.new } let(:db) { driver.db } let(:db2) { driver2.db } let(:test_table) do - db.tables.create("test", columns: [ - {name: "id", type: :int, autoincr: true, primarykey: true}, - {name: "text", type: :varchar} - ]) + db.tables.create( + "test", + columns: [ + {name: "id", type: :int, autoincr: true, primarykey: true}, + {name: "text", type: :varchar} + ] + ) db.tables[:test] end before do driver.before @@ -32,10 +35,26 @@ it "#optimize" do test_table.optimize # FIXME: How to validate? end + it "#rows_count" do + expect(test_table.rows_count).to eq 0 + test_table.insert(text: "Test") + expect(test_table.rows_count).to eq 1 + end + + it "#native?" do + expect(test_table.native?).to eq false + end + + it "#row" do + expect { test_table.row(500) }.to raise_error(Baza::Errors::RowNotFound) + test_table.insert(id: 1, text: "Test") + expect(test_table.row(1)[:text]).to eq "Test" + end + it "#truncate" do test_table db.insert(:test, text: "test") expect(db.select(:test).fetch.fetch(:id).to_i).to eq 1 @@ -50,9 +69,10 @@ end it "#clone" do test_table test_table.create_indexes([{name: "index_on_text", columns: ["text"]}]) + expect(test_table.indexes.length).to eq 1 test_table.insert(text: "test1") test_table.insert(text: "test2")