Sha256: dba3cd101397bb4e6208b9363139fb40a91e19b8bf375ad4d34611d38255fe67

Contents?: true

Size: 622 Bytes

Versions: 2

Compression:

Stored size: 622 Bytes

Contents

RSpec.describe ROM::Relation, '#prefix' do
  subject(:relation) { container.relations.users }

  include_context 'users and tasks'

  before do
    conf.relation(:users) do
      def sorted
        order(:id)
      end
    end
  end

  with_adapters do
    it 'projects the dataset using new column names' do
      prefixed = relation.sorted.prefix(:user)

      expect(prefixed.first).to eql(user_id: 1, user_name: 'Jane')
    end

    it 'uses singularized table name as the default prefix' do
      prefixed = relation.sorted.prefix

      expect(prefixed.first).to eql(user_id: 1, user_name: 'Jane')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-sql-0.9.1 spec/unit/relation/prefix_spec.rb
rom-sql-0.9.0 spec/unit/relation/prefix_spec.rb