aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/cases/arel/nodes/not_test.rb
blob: 481e6787008a25ea64bff03d1868eacc7c208969 (plain) (tree)
1
2
3
4
5
6
7
8
9
                             

                            


              


                                
                                       



                                   

           
 


                                                  


                                         

                                                  


                                         


       
# frozen_string_literal: true

require_relative "../helper"

module Arel
  module Nodes
    describe "not" do
      describe "#not" do
        it "makes a NOT node" do
          attr = Table.new(:users)[:id]
          expr  = attr.eq(10)
          node  = expr.not
          node.must_be_kind_of Not
          node.expr.must_equal expr
        end
      end

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

        it "is not equal with different ivars" do
          array = [Not.new("foo"), Not.new("baz")]
          assert_equal 2, array.uniq.size
        end
      end
    end
  end
end