Sha256: 8740c3bf2432150d5da3f9f9212bfe5e4c760e03be38d3ebe0215fb9a208c78e

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 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::Reference do
  context '#initialize' do
    specify 'parent is required' do
      expect { described_class.new(name: 'a', parent: '') }.to  raise_error(ArgumentError)
      expect { described_class.new(name: 'a', parent: nil) }.to raise_error(ArgumentError)
      expect { described_class.new(name: 'a') }.to raise_error(ArgumentError)
    end
  end

  context 'equality' do
    let(:config) { { name: 'id', parent: 'patient_id' } }

    subject { described_class.new(config) }

    specify '#hash produces same output as string hash of class name, name, and parent' do
      expected_hash = "#{described_class.name}#{config[:name]}#{config[:parent]}".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/reference_spec.rb
dbee-3.0.0 spec/dbee/model/constraints/reference_spec.rb
dbee-2.1.1 spec/dbee/model/constraints/reference_spec.rb
dbee-2.1.0 spec/dbee/model/constraints/reference_spec.rb
dbee-2.1.0.pre.alpha spec/dbee/model/constraints/reference_spec.rb
dbee-2.0.3 spec/dbee/model/constraints/reference_spec.rb
dbee-2.0.2 spec/dbee/model/constraints/reference_spec.rb
dbee-2.0.1 spec/dbee/model/constraints/reference_spec.rb
dbee-2.0.0 spec/dbee/model/constraints/reference_spec.rb
dbee-2.0.0.pre.alpha spec/dbee/model/constraints/reference_spec.rb
dbee-1.2.1 spec/dbee/model/constraints/reference_spec.rb
dbee-1.2.0 spec/dbee/model/constraints/reference_spec.rb
dbee-1.1.0 spec/dbee/model/constraints/reference_spec.rb