Sha256: 6303b391c268de7535a80664447fb9fd4308899a246fd88f67600f1c3a12d2dd

Contents?: true

Size: 905 Bytes

Versions: 17

Compression:

Stored size: 905 Bytes

Contents

RSpec.describe 'PostgreSQL extension', :postgres do
  include_context 'database setup'

  before do
    conn.drop_table?(:pg_people)
    conn.drop_table?(:people)

    conn.create_table :pg_people do
      primary_key :id
      String :name
      column :tags, "text[]"
    end

    conf.relation(:people) do
      schema(:pg_people, infer: true)
    end

    conf.commands(:people) do
      define(:create)
    end
  end

  let(:people_relation) { relations[:people] }

  describe 'using arrays' do
    let(:people) { commands[:people] }

    it 'inserts array values' do
      people.create.call(name: 'John Doe', tags: ['foo'])
      expect(people_relation.to_a).to eq([id: 1, name: 'John Doe', tags: ['foo']])
    end

    it 'inserts empty arrays' do
      people.create.call(name: 'John Doe', tags: [])
      expect(people_relation.to_a).to eq([id: 1, name: 'John Doe', tags: []])
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rom-sql-1.2.2 spec/extensions/postgres/integration_spec.rb
rom-sql-1.2.1 spec/extensions/postgres/integration_spec.rb
rom-sql-1.2.0 spec/extensions/postgres/integration_spec.rb
rom-sql-1.1.2 spec/extensions/postgres/integration_spec.rb
rom-sql-1.1.1 spec/extensions/postgres/integration_spec.rb
rom-sql-1.1.0 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.3 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.2 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.1 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.0 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.0.rc2 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.0.rc1 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.0.beta3 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.0.beta2 spec/extensions/postgres/integration_spec.rb
rom-sql-1.0.0.beta1 spec/extensions/postgres/integration_spec.rb
rom-sql-0.9.1 spec/extensions/postgres/integration_spec.rb
rom-sql-0.9.0 spec/extensions/postgres/integration_spec.rb