Sha256: 05ef6b0ddcdfb23abcadda4684608d81ad892a498d705a2a298faaaf444bf0b4

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true

require_relative "../helper"

class Arel::Nodes::CountTest < Arel::Spec
  describe "as" do
    it "should alias the count" do
      table = Arel::Table.new :users
      _(table[:id].count.as("foo").to_sql).must_be_like %{
        COUNT("users"."id") AS foo
      }
    end
  end

  describe "eq" do
    it "should compare the count" do
      table = Arel::Table.new :users
      _(table[:id].count.eq(2).to_sql).must_be_like %{
        COUNT("users"."id") = 2
      }
    end
  end

  describe "equality" do
    it "is equal with equal ivars" do
      array = [Arel::Nodes::Count.new("foo"), Arel::Nodes::Count.new("foo")]
      assert_equal 1, array.uniq.size
    end

    it "is not equal with different ivars" do
      array = [Arel::Nodes::Count.new("foo"), Arel::Nodes::Count.new("foo!")]
      assert_equal 2, array.uniq.size
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ibm_db-5.5.0 test/cases/arel/nodes/count_test.rb
ibm_db-5.4.1 test/cases/arel/nodes/count_test.rb
ibm_db-5.4.0 test/cases/arel/nodes/count_test.rb
ibm_db-5.3.2 test/cases/arel/nodes/count_test.rb
ibm_db-5.3.1 test/cases/arel/nodes/count_test.rb