Sha256: a103be7e89d017403d093457ac342df90ac21f1443b8699c79c6d695d422821f

Contents?: true

Size: 1.49 KB

Versions: 15

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

RSpec.describe Hydra::PCDM::AncestorChecker do
  context '.former_is_ancestor_of_latter?' do
    subject { described_class.former_is_ancestor_of_latter?(potential_ancestor, record) }
    let(:record) { instance_double(Hydra::PCDM::Object) }
    let(:potential_ancestor) { nil }

    context 'when the potential_ancestor is the record itself' do
      let(:potential_ancestor) { record }
      it { is_expected.to eq(true) }
    end

    context 'when the potential_ancestor has no members' do
      let(:potential_ancestor) { instance_double(Hydra::PCDM::Object, members: []) }
      it { is_expected.to eq(false) }
    end

    context 'when the potential_ancestor includes the given record' do
      let(:potential_ancestor) { instance_double(Hydra::PCDM::Object, members: [record]) }
      it { is_expected.to eq(true) }
    end

    context 'when the potential_ancestor includes a descendant that includes the given record' do
      let(:descendant) { instance_double(Hydra::PCDM::Object, members: [record]) }
      let(:potential_ancestor) { instance_double(Hydra::PCDM::Object, members: [descendant]) }
      it { is_expected.to eq(true) }
    end

    context 'when the potential_ancestor only includes descendants that do not include the given record' do
      let(:descendant) { instance_double(Hydra::PCDM::Object, members: [:another]) }
      let(:potential_ancestor) { instance_double(Hydra::PCDM::Object, members: [descendant]) }
      it { is_expected.to eq(false) }
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hydra-pcdm-1.4.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-1.3.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-1.2.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-1.1.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-1.0.1 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-1.0.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.11.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.10.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.9.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.8.2 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.8.1 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.8.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.8.0.beta1 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.7.0 spec/hydra/pcdm/ancestor_checker_spec.rb
hydra-pcdm-0.6.0 spec/hydra/pcdm/ancestor_checker_spec.rb