spec/unit/identifier_spec.rb in ezid-client-1.2.0 vs spec/unit/identifier_spec.rb in ezid-client-1.3.0
- old
+ new
@@ -117,11 +117,11 @@
end
end
describe "#delete" do
context "when the identifier is reserved" do
- subject { described_class.new(id: "id", status: Identifier::RESERVED) }
+ subject { described_class.new(id: "id", status: Status::RESERVED) }
context "and is persisted" do
before { allow(subject).to receive(:persisted?) { true } }
it "deletes the identifier" do
expect(subject.client).to receive(:delete_identifier).with("id") { double(id: "id") }
subject.delete
@@ -134,11 +134,11 @@
expect { subject.delete }.to raise_error(Error)
end
end
end
context "when identifier is not reserved" do
- subject { described_class.new(id: "id", status: Identifier::PUBLIC) }
+ subject { described_class.new(id: "id", status: Status::PUBLIC) }
it "raises an exception" do
expect { subject.delete }.to raise_error(Error)
end
end
end
@@ -191,11 +191,11 @@
it { is_expected.to be_public }
it { is_expected.not_to be_reserved }
it { is_expected.not_to be_unavailable }
end
context "when the identifier is reserved" do
- before { subject.status = Identifier::RESERVED }
+ before { subject.status = Status::RESERVED }
it { is_expected.not_to be_public }
it { is_expected.to be_reserved }
it { is_expected.not_to be_unavailable }
end
context "when the identifier is unavailable" do
@@ -216,11 +216,11 @@
describe "status-changing methods" do
subject { described_class.new(id: "id", status: status) }
describe "#unavailable!" do
context "when the status is \"unavailable\"" do
- let(:status) { "#{Identifier::UNAVAILABLE} | whatever" }
+ let(:status) { "#{Status::UNAVAILABLE} | whatever" }
context "and no reason is given" do
it "logs a warning" do
pending "https://github.com/duke-libraries/ezid-client/issues/46"
allow_message_expectations_on_nil
expect(subject.logger).to receive(:warn)
@@ -236,46 +236,46 @@
allow_message_expectations_on_nil
expect(subject.logger).to receive(:warn)
subject.unavailable!("because")
end
it "should change the status" do
- expect { subject.unavailable!("because") }.to change(subject, :status).from(status).to("#{Identifier::UNAVAILABLE} | because")
+ expect { subject.unavailable!("because") }.to change(subject, :status).from(status).to("#{Status::UNAVAILABLE} | because")
end
end
end
context "when the status is \"reserved\"" do
- let(:status) { Identifier::RESERVED }
+ let(:status) { Status::RESERVED }
context "and persisted" do
before { allow(subject).to receive(:persisted?) { true } }
it "raises an exception" do
expect { subject.unavailable! }.to raise_error(Error)
end
end
context "and not persisted" do
before { allow(subject).to receive(:persisted?) { false } }
it "changes the status" do
- expect { subject.unavailable! }.to change(subject, :status).from(Identifier::RESERVED).to(Identifier::UNAVAILABLE)
+ expect { subject.unavailable! }.to change(subject, :status).from(Status::RESERVED).to(Status::UNAVAILABLE)
end
end
end
context "when the status is \"public\"" do
- let(:status) { Identifier::PUBLIC }
+ let(:status) { Status::PUBLIC }
context "and no reason is given" do
it "changes the status" do
- expect { subject.unavailable! }.to change(subject, :status).from(Identifier::PUBLIC).to(Identifier::UNAVAILABLE)
+ expect { subject.unavailable! }.to change(subject, :status).from(Status::PUBLIC).to(Status::UNAVAILABLE)
end
end
context "and a reason is given" do
it "changes the status and appends the reason" do
- expect { subject.unavailable!("withdrawn") }.to change(subject, :status).from(Identifier::PUBLIC).to("#{Identifier::UNAVAILABLE} | withdrawn")
+ expect { subject.unavailable!("withdrawn") }.to change(subject, :status).from(Status::PUBLIC).to("#{Status::UNAVAILABLE} | withdrawn")
end
end
end
end
describe "#public!" do
- subject { described_class.new(id: "id", status: Identifier::UNAVAILABLE) }
+ subject { described_class.new(id: "id", status: Status::UNAVAILABLE) }
it "changes the status" do
- expect { subject.public! }.to change(subject, :status).from(Identifier::UNAVAILABLE).to(Identifier::PUBLIC)
+ expect { subject.public! }.to change(subject, :status).from(Status::UNAVAILABLE).to(Status::PUBLIC)
end
end
end
end