require 'spec_helper' describe FedoraMigrate::RepositoryMigrator do let(:namespace) { "sufia" } it { is_expected.to respond_to(:source_objects) } it { is_expected.to respond_to(:failed) } it { is_expected.to respond_to(:namespace) } describe "#failed" do specify "sets to zero" do expect(subject.failed).to eql(0) end end context "when forcing" do before do allow_any_instance_of(FedoraMigrate::RepositoryMigrator).to receive(:source_objects).and_return([]) allow_any_instance_of(FedoraMigrate::RepositoryMigrator).to receive(:failed).and_return(1) end subject { FedoraMigrate::RepositoryMigrator.new(namespace, { force: true }) } specify "migrate relationships if failures are present" do expect(subject.migrate_relationships).to be true end end context "without a given namespace" do describe "#namespace" do specify "is given in the repository profile" do expect(subject.namespace).to eql("changeme") end end end context "with a given namespace" do subject { FedoraMigrate::RepositoryMigrator.new(namespace) } describe "#namespace" do specify "is the one provided" do expect(subject.namespace).to eql(namespace) end end describe "#source_objects" do it "should reuturn an array of all digital objects from Rubydora" do expect(subject.source_objects.collect { |o| o.pid }).to include("sufia:rb68xc089", "sufia:rb68xc11m") end it "should exclude fedora-system objects" do expect(subject.source_objects).to_not include("fedora-system:ContentModel-3.0") expect(subject.source_objects.count).to eql 9 end end end end