Sha256: 73fd4b2d49e8e2e354f7586654b53f0630fef0bf03e6c9f57e7e262f2dad6b7c

Contents?: true

Size: 886 Bytes

Versions: 2

Compression:

Stored size: 886 Bytes

Contents

shared_context 'users and tasks' do
  subject(:rom) { setup.finalize }

  let(:setup) { ROM.setup(postgres: 'postgres://localhost/rom') }
  let(:conn) { setup.postgres.connection }

  before do
    [:users, :tasks, :tags, :task_tags].each { |name| conn.drop_table?(name) }

    conn.create_table :users do
      primary_key :id
      String :name
    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

    conn[:users].insert id: 1, name: 'Piotr'
    conn[:tasks].insert id: 1, user_id: 1, title: 'Finish ROM'
    conn[:tags].insert id: 1, name: 'important'
    conn[:task_tags].insert(tag_id: 1, task_id: 1)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-sql-0.1.1 spec/shared/users_and_tasks.rb
rom-sql-0.1.0 spec/shared/users_and_tasks.rb