Sha256: 9c4e24a9d5ebb29db39f77b6e2d68a090e7bee9009e8ba3091f96246eb8d5c05

Contents?: true

Size: 771 Bytes

Versions: 16

Compression:

Stored size: 771 Bytes

Contents

require 'spec_helper'

RSpec.describe 'Defining a view using schemas', seeds: false do
  include_context 'users'

  with_adapters do
    describe 'defining a projected view' do
      before do
        conf.relation(:users) do
          schema(infer: true)

          view(:names) do
            schema { project(:name) }
            relation { order(:name, :id) }
          end
        end

        container.relations[:users].insert(name: 'Joe')
        container.relations[:users].insert(name: 'Jane')
        container.relations[:users].insert(name: 'Jade')
      end

      it 'automatically projects a relation view' do
        expect(relations[:users].names.to_a)
          .to eql([{ name: 'Jade' }, { name: 'Jane' }, { name: 'Joe' }])
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rom-sql-1.3.5 spec/integration/schema/view_spec.rb
rom-sql-1.3.4 spec/integration/schema/view_spec.rb
rom-sql-2.0.0.beta2 spec/integration/schema/view_spec.rb
rom-sql-2.0.0.beta1 spec/integration/schema/view_spec.rb
rom-sql-1.3.3 spec/integration/schema/view_spec.rb
rom-sql-1.3.2 spec/integration/schema/view_spec.rb
rom-sql-1.3.1 spec/integration/schema/view_spec.rb
rom-sql-1.3.0 spec/integration/schema/view_spec.rb
rom-sql-1.2.2 spec/integration/schema/view_spec.rb
rom-sql-1.2.1 spec/integration/schema/view_spec.rb
rom-sql-1.2.0 spec/integration/schema/view_spec.rb
rom-sql-1.1.2 spec/integration/schema/view_spec.rb
rom-sql-1.1.1 spec/integration/schema/view_spec.rb
rom-sql-1.1.0 spec/integration/schema/view_spec.rb
rom-sql-1.0.3 spec/integration/schema/view_spec.rb
rom-sql-1.0.2 spec/integration/schema/view_spec.rb