Sha256: acd9aa37bd6b3227418af5d576e651b029603ee8a1c7122eec6c916b6d3cfde6
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'spec_helper' RSpec.describe ROM::SQL::OrderDSL, :postgres, helpers: true do include_context 'database setup' subject(:dsl) do ROM::SQL::OrderDSL.new(schema) end let(:schema) do define_schema(:users, id: ROM::SQL::Types::Serial, name: ROM::SQL::Types::String) end let(:ds) do conn[:users] end describe '#call' do it 'returns an array with ordered expressions' do expect(dsl.call { id }.first.sql_literal(conn[:users])).to eql('"id"') end end describe '#method_missing' do it 'responds to methods matching attribute names' do expect(dsl.id.name).to be(:id) expect(dsl.name.name).to be(:name) end it 'delegates to sequel virtual row' do expect(dsl.call { nullif(id.qualified, `''`).desc }.first.sql_literal(conn[:users])). to eql(%(NULLIF("users"."id", '') DESC)) end it 'allows to set nulls first/last' do expect(dsl.call { id.desc(nulls: :first) }.first.sql_literal(conn[:users])). to eql(%("id" DESC NULLS FIRST)) expect(dsl.call { id.desc(nulls: :last) }.first.sql_literal(conn[:users])). to eql(%("id" DESC NULLS LAST)) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rom-sql-1.3.1 | spec/unit/order_dsl_spec.rb |
rom-sql-1.3.0 | spec/unit/order_dsl_spec.rb |