Sha256: b8a2556fbaf7f4a154dbaa61fa3b7f4be58d21e22353d8f2fc5f4cc74e87df47
Contents?: true
Size: 897 Bytes
Versions: 3
Compression:
Stored size: 897 Bytes
Contents
require 'rom/sql/function' RSpec.describe ROM::SQL::Function, :postgres do subject(:func) { ROM::SQL::Function.new(type) } include_context 'database setup' let(:ds) { container.gateways[:default][:users] } let(:type) { ROM::SQL::Types::Int } describe '#sql_literal' do context 'without alias' do specify do expect(func.count(:id).sql_literal(ds)).to eql(%(COUNT("id"))) end end context 'with alias' do specify do expect(func.count(:id).as(:count).sql_literal(ds)).to eql(%(COUNT("id") AS "count")) end end end describe '#method_missing' do it 'responds to anything when not set' do expect(func.count(:id)).to be_instance_of(func.class) end it 'raises error when is set already' do expect { func.count(:id).upper.sql_literal(ds) }. to raise_error(NoMethodError, /upper/) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rom-sql-1.0.0.rc2 | spec/unit/function_spec.rb |
rom-sql-1.0.0.rc1 | spec/unit/function_spec.rb |
rom-sql-1.0.0.beta3 | spec/unit/function_spec.rb |