Sha256: ba102bd5c3910e9b4acadd11b3b25f40f39cecdad56d445415c3e8f4d9dfe671

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 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
    test_database.table("test").drop if test_database.table_exists?("test")

    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

7 entries across 7 versions & 1 rubygems

Version Path
baza-0.0.38 spec/support/driver_databases_collection.rb
baza-0.0.37 spec/support/driver_databases_collection.rb
baza-0.0.36 spec/support/driver_databases_collection.rb
baza-0.0.35 spec/support/driver_databases_collection.rb
baza-0.0.34 spec/support/driver_databases_collection.rb
baza-0.0.33 spec/support/driver_databases_collection.rb
baza-0.0.32 spec/support/driver_databases_collection.rb