Sha256: d238fc2718865016ca460ba9d5c15e07fce7bb7521bbe4f7c0ae784f10f598f7

Contents?: true

Size: 932 Bytes

Versions: 3

Compression:

Stored size: 932 Bytes

Contents

require 'spec_helper'

describe Sufia::IdService do
  describe "mint" do
    subject { Sufia::IdService.mint }

    it { should_not be_empty }

    it "should not mint the same id twice in a row" do
      expect(Sufia::IdService.mint).to_not eq subject
    end

    it "should be valid" do    
      expect(Sufia::IdService.valid?(subject)).to be true
    end

    context "when the pid already exists in Fedora" do
      let(:mock_pid) { 'scholarsphere:ef12ef12f' }
      let(:unique_pid) {  'scholarsphere:bb22bb22b' }

      before do
        allow(Sufia::IdService).to receive(:next_id).and_return(mock_pid, unique_pid)
        expect(ActiveFedora::Base).to receive(:exists?).with(mock_pid).and_return(true)
        expect(ActiveFedora::Base).to receive(:exists?).with(unique_pid).and_return(false)
      end

      it "should not assign that pid again" do
        expect(subject).to eq unique_pid
      end
    end
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sufia-4.0.1 spec/lib/sufia/id_service_spec.rb
sufia-4.0.0 spec/lib/sufia/id_service_spec.rb
sufia-4.0.0.rc2 spec/lib/sufia/id_service_spec.rb