Sha256: 3ef3bcaf83e7f98f503112a5ad30eb5b632f810ed5aacef77a493cbf936522df

Contents?: true

Size: 1.36 KB

Versions: 113

Compression:

Stored size: 1.36 KB

Contents

require 'helper'

module Arel
  module Nodes
    describe 'sql literal' do
      before do
        @visitor = Visitors::ToSql.new Table.engine.connection_pool
      end

      describe 'sql' do
        it 'makes a sql literal node' do
          sql = Arel.sql 'foo'
          sql.must_be_kind_of Arel::Nodes::SqlLiteral
        end
      end

      describe 'count' do
        it 'makes a count node' do
          node = SqlLiteral.new('*').count
          @visitor.accept(node).must_be_like %{ COUNT(*) }
        end

        it 'makes a distinct node' do
          node = SqlLiteral.new('*').count true
          @visitor.accept(node).must_be_like %{ COUNT(DISTINCT *) }
        end
      end

      describe 'equality' do
        it 'makes an equality node' do
          node = SqlLiteral.new('foo').eq(1)
          @visitor.accept(node).must_be_like %{ foo = 1 }
        end
      end

      describe 'grouped "or" equality' do
        it 'makes a grouping node with an or node' do
          node = SqlLiteral.new('foo').eq_any([1,2])
          @visitor.accept(node).must_be_like %{ (foo = 1 OR foo = 2) }
        end
      end

      describe 'grouped "and" equality' do
        it 'makes a grouping node with an or node' do
          node = SqlLiteral.new('foo').eq_all([1,2])
          @visitor.accept(node).must_be_like %{ (foo = 1 AND foo = 2) }
        end
      end
    end
  end
end

Version data entries

113 entries across 95 versions & 14 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/arel-3.0.3/test/nodes/test_sql_literal.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/arel-3.0.3/test/nodes/test_sql_literal.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/arel-3.0.3/test/nodes/test_sql_literal.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/arel-3.0.3/test/nodes/test_sql_literal.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/arel-3.0.3/test/nodes/test_sql_literal.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/arel-3.0.3/test/nodes/test_sql_literal.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/arel-3.0.3/test/nodes/test_sql_literal.rb
arel-3.0.3 test/nodes/test_sql_literal.rb
swipe-rails-0.0.5 vendor/bundle/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
challah-1.0.0.beta3 vendor/bundle/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
challah-1.0.0.beta2 vendor/bundle/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
challah-1.0.0.beta vendor/bundle/gems/arel-3.0.2/test/nodes/test_sql_literal.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/nodes/test_sql_literal.rb