Sha256: 150b16919d3923af357fbaac1a8a6543a1ddcbd5a71881fba13c6e5331f81ab1

Contents?: true

Size: 797 Bytes

Versions: 3

Compression:

Stored size: 797 Bytes

Contents

require 'spec_helper'

describe 'Inferring schema from database' do
  let(:setup) { ROM.setup(postgres: "postgres://localhost/rom") }

  context "when database schema exists" do
    after { rom.postgres.connection.drop_table?(:people) }

    let(:rom) { setup.finalize }

    it "infers the schema from the database relations" do
      setup.postgres.connection.create_table :people do
        primary_key :id
        String :name
      end

      schema = rom.schema

      expect(schema.people.to_a).to eql(rom.postgres.people.to_a)
      expect(schema.people.header).to eql([:id, :name])
    end
  end

  context "for empty database schemas" do
    it "returns an empty schema" do
      rom = setup.finalize
      schema = rom.schema

      expect(schema.postgres).to be(nil)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-sql-0.2.0 spec/unit/schema_spec.rb
rom-sql-0.1.1 spec/unit/schema_spec.rb
rom-sql-0.1.0 spec/unit/schema_spec.rb