Sha256: 13018f6c0cca0fdec7b53d6c2d40118aaa05718c170c9cc12da4ddaa7aa8311b
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'spec_helper' require 'active_fedora' describe ActiveFedora::Noid::SynchronizedMinter do it { is_expected.to respond_to(:mint) } it 'has a default template' do expect(subject.template).to eq ActiveFedora::Noid.config.template end it 'has a default template' do expect(subject.template).to eq ActiveFedora::Noid.config.template end describe '#initialize' do let(:template) { '.rededk' } let(:statefile) { '/tmp/foobar' } subject { ActiveFedora::Noid::SynchronizedMinter.new(template, statefile) } it 'respects the custom template' do expect(subject.template).to eq template end it 'respects the custom statefile' do expect(subject.statefile).to eq statefile end end describe '#mint' do before do allow(ActiveFedora::Base).to receive(:exists?).and_return(false) end subject { ActiveFedora::Noid::Service.new.mint } it { is_expected.not_to be_empty } it 'does not mint the same ID twice in a row' do expect(subject).not_to eq ActiveFedora::Noid::Service.new.mint end it 'is valid' do expect(ActiveFedora::Noid::Service.new.valid?(subject)).to be true end end context "when the pid already exists in Fedora" do let(:existing_pid) { 'ef12ef12f' } let(:unique_pid) { 'bb22bb22b' } before do allow_any_instance_of(ActiveFedora::Noid::SynchronizedMinter).to receive(:next_id).and_return(existing_pid, unique_pid) allow(ActiveFedora::Base).to receive(:exists?).with(existing_pid).and_return(true) allow(ActiveFedora::Base).to receive(:exists?).with(unique_pid).and_return(false) end it 'skips the existing pid' do expect(subject.mint).to eq unique_pid end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_fedora-noid-0.3.0 | spec/unit/synchronized_minter_spec.rb |