spec/lib/ezid/client_spec.rb in ezid-client-0.1.0 vs spec/lib/ezid/client_spec.rb in ezid-client-0.1.1
- old
+ new
@@ -1,79 +1,89 @@
module Ezid
RSpec.describe Client do
describe "initialization" do
describe "without a block" do
- subject { described_class.new(user: TEST_USER) }
it "should not be logged in" do
expect(subject).not_to be_logged_in
end
end
describe "with a block", :vcr do
it "should be logged in" do
- described_class.new(user: TEST_USER) do |client|
+ described_class.new do |client|
expect(client).to be_logged_in
end
end
end
- end
-
+ end
describe "authentication", :vcr do
- subject { described_class.new(user: TEST_USER) }
describe "logging in" do
before { subject.login }
it "should be logged in" do
expect(subject).to be_logged_in
end
end
describe "logging out" do
- before { subject.login; subject.logout }
+ before { subject.login }
it "should not be logged in" do
+ subject.logout
expect(subject).not_to be_logged_in
end
end
end
- describe "creating an identifier" do
+ describe "creating an identifier", :vcr do
# TODO
end
describe "minting an identifier", :vcr do
- let(:client) { described_class.new(user: TEST_USER) }
describe "which is an ARK" do
- subject { client.mint_identifier(ARK_SHOULDER) }
it "should be a success" do
- expect(subject).to be_success
- expect(subject.message).to match(/#{ARK_SHOULDER}/)
+ response = subject.mint_identifier(ARK_SHOULDER)
+ expect(response).to be_success
+ expect(response.message).to match(/#{ARK_SHOULDER}/)
end
end
describe "which is a DOI" do
- subject { client.mint_identifier(DOI_SHOULDER, doi_metadata) }
it "should be a sucess" do
- expect(subject).to be_success
- expect(subject.message).to match(/#{DOI_SHOULDER}/)
- expect(subject.message).to match(/\| ark:/)
+ response = subject.mint_identifier(DOI_SHOULDER, doi_metadata)
+ expect(response).to be_success
+ expect(response.message).to match(/#{DOI_SHOULDER}/)
+ expect(response.message).to match(/\| ark:/)
end
end
end
- describe "getting identifier metadata", :vcr do
- let(:client) { described_class.new(user: TEST_USER) }
- let(:metadata) { Metadata.new("dc.title" => "Test") }
- let(:identifier) { client.mint_identifier(ARK_SHOULDER, metadata).message }
- subject { Metadata.new(client.get_identifier_metadata(identifier).content.last) }
+ describe "getting identifier metadata" do
+ before do
+ @identifier = subject.mint_identifier(ARK_SHOULDER).identifier
+ end
it "should return the metadata" do
- expect(subject["dc.title"]).to eq("Test")
+ response = subject.get_identifier_metadata(@identifier)
+ expect(response.body).to match(/_status: public/)
end
end
describe "modifying an identifier" do
- # TODO
+ before do
+ @identifier = subject.mint_identifier(ARK_SHOULDER).identifier
+ end
+ it "should update the metadata" do
+ subject.modify_identifier(@identifier, "dc.title" => "Test")
+ response = subject.get_identifier_metadata(@identifier)
+ expect(response.body).to match(/dc.title: Test/)
+ end
end
describe "deleting an identifier" do
- # TODO
+ before do
+ @identifier = subject.mint_identifier(ARK_SHOULDER, "_status" => "reserved").identifier
+ end
+ it "should delete the identifier" do
+ response = subject.delete_identifier(@identifier)
+ expect(response).to be_success
+ expect { subject.get_identifier_metadata(@identifier) }.to raise_error
+ end
end
describe "server status", :vcr do
- let(:client) { described_class.new(user: TEST_USER) }
- subject { client.server_status("*") }
it "should report the status of EZID and subsystems" do
- expect(subject).to be_success
- expect(subject.message).to eq "EZID is up"
+ response = subject.server_status("*")
+ expect(response).to be_success
+ expect(response.message).to eq("EZID is up")
end
end
end
end