Sha256: 5ce6c5376a8d9fc3eab6f4c3d47093b9268d969c95b324e00e604f6e019bb206

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents


module Ezid
  RSpec.describe Identifier do

    describe "CRUD operations" do
      describe "create" do
        describe "with a shoulder" do
          subject { described_class.create(shoulder: ARK_SHOULDER) }
          it "should mint an identifier" do
            expect(subject).to be_a(described_class)
            expect(subject.id).to match(/#{ARK_SHOULDER}/)
          end
        end
        describe "with an id" do
          let(:minted) { described_class.create(shoulder: ARK_SHOULDER) }
          subject { described_class.create(id: "#{minted}/123") }
          it "should create the identifier" do
            expect(subject).to be_a(described_class)
            expect(subject.id).to eq("#{minted}/123")
          end
        end
      end

      describe "retrieve" do
        let(:minted) { described_class.create(shoulder: ARK_SHOULDER, target: "http://example.com") }
        subject { described_class.find(minted.id) }
        it "should instantiate the identifier" do
          expect(subject).to be_a(described_class)
          expect(subject.id).to eq(minted.id)
          expect(subject.target).to eq("http://example.com")
        end
      end

      describe "update" do
        subject { described_class.create(shoulder: ARK_SHOULDER, target: "http://google.com") }
        before do
          subject.target = "http://example.com"
          subject.save
        end
        it "should update the metadata" do
          expect(subject.target).to eq("http://example.com")
        end
      end

      describe "delete" do
        subject { described_class.create(shoulder: ARK_SHOULDER, status: "reserved") }
        before { subject.delete }
        it "should delete the identifier" do
          expect { described_class.find(subject.id) }.to raise_error
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ezid-client-0.6.0 spec/integration/identifier_spec.rb