Sha256: 1ce1924074b2c8cdb6aed8b3622132a8275b9904d2852f86eda93373fd05fb45

Contents?: true

Size: 1.38 KB

Versions: 16

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
module Finitio
  describe Heading, "hash" do

    let(:r)      { Attribute.new(:r, intType)        }
    let(:b)      { Attribute.new(:b, intType)        }
    let(:maybe_r){ Attribute.new(:r, intType, false) }

    def heading(attributes, options = nil)
      Heading.new(attributes, options)
    end

    it 'returns same code on equal headings' do
      expect(heading([r]).hash).to eq(heading([r]).hash)
    end

    it 'does not put significance to attributes ordering' do
      expect(heading([r, b]).hash).to eq(heading([b, r]).hash)
    end

    it 'is good enough to distinguish between attribute obligations' do
      expect(heading([r]).hash).not_to eq(heading([maybe_r]).hash)
    end

    it 'is good enough to distinguish between extra allowance' do
      h1 = heading([r], allow_extra: true)
      h2 = heading([r], allow_extra: false)
      h3 = heading([r], allow_extra: anyType)
      h4 = heading([r], allow_extra: intType)
      h5 = heading([r], allow_extra: intType)
      expect(h1.hash).not_to eq(h2.hash)
      expect(h1.hash).to eq(h3.hash)
      expect(h1.hash).not_to eq(h4.hash)
      expect(h4.hash).to eq(h5.hash)
    end

    it 'is be good enough to distinguish between different headings' do
      a1 = Attribute.new(:r, intType)
      a2 = Attribute.new(:r, floatType)
      expect(heading([a1]).hash).not_to eq(heading([a2]).hash)
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/heading/test_hash.rb
finitio-0.11.4 spec/heading/test_hash.rb
finitio-0.11.3 spec/heading/test_hash.rb
finitio-0.11.2 spec/heading/test_hash.rb
finitio-0.11.1 spec/heading/test_hash.rb
finitio-0.10.0 spec/heading/test_hash.rb
finitio-0.9.1 spec/heading/test_hash.rb
finitio-0.9.0 spec/heading/test_hash.rb
finitio-0.8.0 spec/heading/test_hash.rb
finitio-0.7.0 spec/heading/test_hash.rb
finitio-0.7.0.pre.rc4 spec/heading/test_hash.rb
finitio-0.7.0.pre.rc3 spec/heading/test_hash.rb
finitio-0.7.0.pre.rc2 spec/heading/test_hash.rb
finitio-0.7.0.pre.rc1 spec/heading/test_hash.rb
finitio-0.6.1 spec/heading/test_hash.rb
finitio-0.6.0 spec/heading/test_hash.rb