spec/unit/metadata_spec.rb in ezid-client-0.4.2 vs spec/unit/metadata_spec.rb in ezid-client-0.5.0
- old
+ new
@@ -1,15 +1,15 @@
module Ezid
RSpec.describe Metadata do
describe "reserved elements" do
describe "readers" do
- Metadata::RESERVED_ELEMENTS.each do |element|
- next if element == "_crossref"
+ Metadata::RESERVED_ELEMENTS.each do |element|
it "should have a reader for '#{element}'" do
expect(subject).to receive(:reader).with(element)
- subject.send(element.sub("_", ""))
+ reader = (element == "_crossref") ? element : element.sub("_", "")
+ subject.send(reader)
end
end
describe "for time-based elements" do
Metadata::RESERVED_TIME_ELEMENTS.each do |element|
context "\"#{element}\"" do
@@ -25,11 +25,12 @@
describe "writers" do
Metadata::RESERVED_READWRITE_ELEMENTS.each do |element|
next if element == "_crossref"
it "should have a writer for '#{element}'" do
expect(subject).to receive(:writer).with(element, "value")
- subject.send("#{element.sub('_', '')}=", "value")
+ writer = ((element == "_crossref") ? element : element.sub("_", "")).concat("=")
+ subject.send(writer, "value")
end
end
end
end
describe "metadata profiles" do
@@ -48,9 +49,18 @@
it "should have a writer for '#{profile}.#{element}'" do
expect(subject).to receive(:writer).with("#{profile}.#{element}", "value")
subject.send("#{profile}_#{element}=", "value")
end
end
+ end
+ next if profile == "dc"
+ it "should have a reader for '#{profile}'" do
+ expect(subject).to receive(:reader).with(profile)
+ subject.send(profile)
+ end
+ it "should have a writer for '#{profile}'" do
+ expect(subject).to receive(:writer).with(profile, "value")
+ subject.send("#{profile}=", "value")
end
end
end
end