Sha256: 3d49bd71546c6b26eda9023f0d0912c29e3d6bb75d9127cb864eafe234c2868e

Contents?: true

Size: 1011 Bytes

Versions: 19

Compression:

Stored size: 1011 Bytes

Contents

require 'spec_helper'
module Finitio
  describe Constraint, "==" do

    def constraint(proc, name = nil)
      Constraint.new(proc, name)
    end

    it 'recognizes same procs' do
      expect(constraint(byte_min)).to eq(constraint(byte_min))
    end

    it 'recognizes non constraints' do
      expect(constraint(byte_min)).not_to eq(nil)
      expect(constraint(byte_min)).not_to eq(1)
    end

    it 'recognizes non equivalent constraints' do
      expect(constraint(byte_min)).not_to eq(constraint(byte_max))
    end

    it 'does not take name into accound' do
      expect(constraint(byte_min, :foo)).to eq(constraint(byte_min, :bar))
    end

    it 'implements hash accordingly' do
      c1 = constraint(byte_min)
      c2 = constraint(byte_min)
      expect(c1.hash).to eq(c2.hash)
    end

    it 'is smart enough to have different hash codes for different constraints' do
      c1 = constraint(byte_min)
      c2 = constraint(byte_max)
      expect(c1.hash).not_to eq(c2.hash)
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/constraint/test_equality.rb
finitio-0.11.4 spec/constraint/test_equality.rb
finitio-0.11.3 spec/constraint/test_equality.rb
finitio-0.11.2 spec/constraint/test_equality.rb
finitio-0.11.1 spec/constraint/test_equality.rb
finitio-0.10.0 spec/constraint/test_equality.rb
finitio-0.9.1 spec/constraint/test_equality.rb
finitio-0.9.0 spec/constraint/test_equality.rb
finitio-0.8.0 spec/constraint/test_equality.rb
finitio-0.7.0 spec/constraint/test_equality.rb
finitio-0.7.0.pre.rc4 spec/constraint/test_equality.rb
finitio-0.7.0.pre.rc3 spec/constraint/test_equality.rb
finitio-0.7.0.pre.rc2 spec/constraint/test_equality.rb
finitio-0.7.0.pre.rc1 spec/constraint/test_equality.rb
finitio-0.6.1 spec/constraint/test_equality.rb
finitio-0.6.0 spec/constraint/test_equality.rb
finitio-0.5.2 spec/constraint/test_equality.rb
finitio-0.5.1 spec/constraint/test_equality.rb
finitio-0.5.0 spec/constraint/test_equality.rb