Sha256: 32da1b3231e39bd33a8b67d647625445803dd6b9ba3856be6353628f25bf7eac

Contents?: true

Size: 961 Bytes

Versions: 2

Compression:

Stored size: 961 Bytes

Contents

require 'spec_helper'
require 'active_fedora/noid/service'
require 'active_fedora/noid/synchronized_minter'

describe ActiveFedora::Noid::Service do
  describe 'public API' do
    it { is_expected.to respond_to(:valid?) }
    it { is_expected.to respond_to(:mint) }
  end

  it 'has a default minter' do
    expect(subject.minter).to be_instance_of ActiveFedora::Noid::SynchronizedMinter
  end

  context 'with a custom minter' do
    let(:minter) { double('minter') }
    let(:identifier) { 'abc123' }
    let(:new_service) { ActiveFedora::Noid::Service.new(minter) }

    it 'allows injecting a custom minter' do
      expect(new_service.minter).to eq minter
    end

    it 'delegates validity checking to the minter' do
      expect(minter).to receive(:valid?).with(identifier).once
      new_service.valid? identifier
    end

    it 'delegates minting to the minter' do
      expect(minter).to receive(:mint).once
      new_service.mint
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_fedora-noid-0.1.0 spec/unit/service_spec.rb
active_fedora-noid-0.0.1 spec/unit/service_spec.rb