Sha256: b928f0a29067ca4ea891a8273650cde1e8b10af01f0960dc1253b79da2380be4

Contents?: true

Size: 796 Bytes

Versions: 3

Compression:

Stored size: 796 Bytes

Contents

RSpec.shared_context 'database' do
  let(:configuration) { ROM::Configuration.new(:sql, uri).use(:macros) }
  let(:conn) { configuration.gateways[:default].connection }
  let(:rom) { ROM.container(configuration) }
  let(:uri) { 'postgres://localhost/rom_repository' }

  before do
    conn.loggers << LOGGER

    [:tags, :tasks, :users].each { |table| conn.drop_table?(table) }

    conn.create_table :users do
      primary_key :id
      column :name, String
    end

    conn.create_table :tasks do
      primary_key :id
      foreign_key :user_id, :users, null: false, on_delete: :cascade
      column :title, String
    end

    conn.create_table :tags do
      primary_key :id
      foreign_key :task_id, :tasks, null: false, on_delete: :cascade
      column :name, String
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-repository-0.2.0 spec/shared/database.rb
rom-repository-0.2.0.rc1 spec/shared/database.rb
rom-repository-0.2.0.beta1 spec/shared/database.rb