Sha256: b0ea09a19b8b014012a3be18deb3155377e5574ee931aab022f02ef0ee723590

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

shared_examples_for "a baza databases driver" do
  let(:driver) { constant.new }
  let(:driver2) { constant.new }
  let(:db) { driver.db }
  let(:db2) { driver2.db }
  let(:test_database) do
    db.databases.create(name: "baza-test-create", if_not_exists: true)
    db.databases["baza-test-create"]
  end

  it "renames database" do
    begin
      db.databases["renamed-db"].drop
    # rubocop:disable Lint/HandleExceptions
    rescue Baza::Errors::DatabaseNotFound
      # rubocop:enable Lint/HandleExceptions
      # Ignore - it shouldn't exist
    end

    test_database.name = "renamed-db"
    test_database.save!

    expect(test_database.name).to eq "renamed-db"
  end

  it "drops databases" do
    test_database.drop
    expect { db.databases["baza-test-create"] }.to raise_error(Baza::Errors::DatabaseNotFound)
  end

  it "creates tables" do
    if test_database.table_exists?("test")
      puts "DROPPING TEST TABLE"
      test_database.table("test").drop
    end

    test_database.create_table(
      "test",
      columns: [
        {name: :id, type: :int, autoincr: true, primarykey: true},
        {name: :name, type: :varchar}
      ]
    )

    tables = test_database.tables.map(&:name).to_a
    expect(tables).to eq ["test"]

    table = test_database.table("test")
    expect(table.name).to eq "test"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
baza-0.0.26 spec/support/driver_databases_collection.rb
baza-0.0.25 spec/support/driver_databases_collection.rb
baza-0.0.24 spec/support/driver_databases_collection.rb
baza-0.0.23 spec/support/driver_databases_collection.rb
baza-0.0.22 spec/support/driver_databases_collection.rb
baza-0.0.21 spec/support/driver_databases_collection.rb