Sha256: 9a7f3e4ac5c2d49b2c2e0cf6fdfbf3a0c090a3cd9b7af767b71285815dfd6460

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

#
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

require 'spec_helper'

describe Dbee::Model::Constraints::Static do
  context 'equality' do
    let(:config) { { name: 'type', value: 'general' } }

    subject { described_class.new(config) }

    describe '#initialize' do
      it 'requires either a name or parent' do
        expect { described_class.new }.to                         raise_error(ArgumentError)
        expect { described_class.new(name: '', parent: '') }.to   raise_error(ArgumentError)
        expect { described_class.new(name: nil, parent: nil) }.to raise_error(ArgumentError)
      end
    end

    specify '#hash produces same output as concatenated string hash of name and parent' do
      parent_hash   = "#{described_class.name}#{config[:name]}#{config[:parent]}".hash
      expected_hash = "#{parent_hash}#{config[:value]}".hash

      expect(subject.hash).to eq(expected_hash)
    end

    specify '#== and #eql? compare attributes' do
      object2 = described_class.new(config)

      expect(subject).to eq(object2)
      expect(subject).to eql(object2)
    end

    it 'returns false unless comparing same object types' do
      expect(subject).not_to eq(config)
      expect(subject).not_to eq(nil)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dbee-3.1.0 spec/dbee/model/constraints/static_spec.rb
dbee-3.0.0 spec/dbee/model/constraints/static_spec.rb
dbee-2.1.1 spec/dbee/model/constraints/static_spec.rb
dbee-2.1.0 spec/dbee/model/constraints/static_spec.rb
dbee-2.1.0.pre.alpha spec/dbee/model/constraints/static_spec.rb
dbee-2.0.3 spec/dbee/model/constraints/static_spec.rb
dbee-2.0.2 spec/dbee/model/constraints/static_spec.rb
dbee-2.0.1 spec/dbee/model/constraints/static_spec.rb
dbee-2.0.0 spec/dbee/model/constraints/static_spec.rb
dbee-2.0.0.pre.alpha spec/dbee/model/constraints/static_spec.rb
dbee-1.2.1 spec/dbee/model/constraints/static_spec.rb
dbee-1.2.0 spec/dbee/model/constraints/static_spec.rb
dbee-1.1.0 spec/dbee/model/constraints/static_spec.rb