aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/arel/nodes/binary_test.rb
blob: d160e7cd9d280d4ba48c4992480a84352508b39a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require_relative "../helper"

module Arel
  module Nodes
    class NodesTest < Arel::Spec
      describe "Binary" do
        describe "#hash" do
          it "generates a hash based on its value" do
            eq = Equality.new("foo", "bar")
            eq2 = Equality.new("foo", "bar")
            eq3 = Equality.new("bar", "baz")

            assert_equal eq.hash, eq2.hash
            assert_not_equal eq.hash, eq3.hash
          end

          it "generates a hash specific to its class" do
            eq = Equality.new("foo", "bar")
            neq = NotEqual.new("foo", "bar")

            assert_not_equal eq.hash, neq.hash
          end
        end
      end
    end
  end
end