Sha256: 7e3806fa033fa1286a2f56a1672bf7733d9342413e4a1dbbd47c8d033b5cd11d

Contents?: true

Size: 1.27 KB

Versions: 18

Compression:

Stored size: 1.27 KB

Contents

require "spec_helper"

shared_examples_for "a baza users driver" do
  let(:driver) { constant.new }
  let(:db) { driver.db }
  let(:test_user_name) { "baza-test-create" }
  let(:user) { db.users.create(name: test_user_name, host: "localhost", password: "mypassword") }

  before do
    # Drop any existing user with the test user name
    begin
      db.users.find_by_name(test_user_name).drop
    rescue Baza::Errors::UserNotFound # rubocop:disable Lint/HandleExceptions
    end
  end

  it "Users#list" do
    root_found = false
    db.users.list do |user|
      if user.name == "root"
        root_found = true
        break
      end
    end

    expect(root_found).to eq true
  end

  it "Users#find_by_name" do
    root_user = db.users.find_by_name("root")
    expect(root_user.name).to eq "root"
  end

  it "Users#create" do
    my_user = db.users.create(name: test_user_name, host: "localhost", password: "mypassword")

    expect(my_user.name).to eq test_user_name
    expect(my_user.host).to eq "localhost"
  end

  it "User#drop" do
    user.drop
    expect { db.users.find_by_name(test_user_name) }.to raise_error(Baza::Errors::UserNotFound)
  end

  it "User#name" do
    expect(user.name).to eq test_user_name
  end

  it "User#host" do
    expect(user.host).to eq "localhost"
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
baza-0.0.38 spec/support/driver_users_collection.rb
baza-0.0.37 spec/support/driver_users_collection.rb
baza-0.0.36 spec/support/driver_users_collection.rb
baza-0.0.35 spec/support/driver_users_collection.rb
baza-0.0.34 spec/support/driver_users_collection.rb
baza-0.0.33 spec/support/driver_users_collection.rb
baza-0.0.32 spec/support/driver_users_collection.rb
baza-0.0.31 spec/support/driver_users_collection.rb
baza-0.0.30 spec/support/driver_users_collection.rb
baza-0.0.29 spec/support/driver_users_collection.rb
baza-0.0.28 spec/support/driver_users_collection.rb
baza-0.0.27 spec/support/driver_users_collection.rb
baza-0.0.26 spec/support/driver_users_collection.rb
baza-0.0.25 spec/support/driver_users_collection.rb
baza-0.0.24 spec/support/driver_users_collection.rb
baza-0.0.23 spec/support/driver_users_collection.rb
baza-0.0.22 spec/support/driver_users_collection.rb
baza-0.0.21 spec/support/driver_users_collection.rb