Sha256: 2da9b86bf2f11d94f87922616178ae735b45d074e4accbd233a185f4e5e95e5d

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

shared_context 'database setup' do
  subject(:rom) { setup.finalize }

  let(:uri) { DB_URI }
  let(:conn) { Sequel.connect(uri) }
  let(:setup) { ROM.setup(:sql, conn) }

  def drop_tables
    [:users, :tasks, :tags, :task_tags, :rabbits, :carrots, :schema_migrations].each do |name|
      conn.drop_table?(name)
    end
  end

  before do
    conn.loggers << LOGGER

    drop_tables

    conn.create_table :users do
      primary_key :id
      String :name, null: false
      index :name, unique: true
    end

    conn.create_table :tasks do
      primary_key :id
      Integer :user_id
      String :title
    end

    conn.create_table :tags do
      primary_key :id
      String :name
    end

    conn.create_table :task_tags do
      primary_key :tag_id, :task_id
      Integer :tag_id
      Integer :task_id
    end
  end

  after do
    conn.disconnect
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-sql-0.4.1 spec/shared/database_setup.rb