spec/integration/identifier_spec.rb in ezid-client-0.5.0 vs spec/integration/identifier_spec.rb in ezid-client-0.6.0
- old
+ new
@@ -1,21 +1,55 @@
+
+
module Ezid
RSpec.describe Identifier do
- it "should handle CRUD operations" do
- # create (mint)
- identifier = described_class.create(shoulder: ARK_SHOULDER)
- expect(identifier.status).to eq("public")
- # update
- identifier.target = "http://example.com"
- identifier.save
- # retrieve
- identifier = described_class.find(identifier.id)
- expect(identifier.target).to eq("http://example.com")
- # delete
- identifier = described_class.create(shoulder: ARK_SHOULDER, status: "reserved")
- identifier.delete
- expect { described_class.find(identifier.id) }.to raise_error
- end
+ 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