spec/unit/metadata_spec.rb in ezid-client-1.1.1 vs spec/unit/metadata_spec.rb in ezid-client-1.2.0

- old
+ new

@@ -6,26 +6,26 @@ it "writes the \"#{writer}\" element" do subject.send("#{writer}=", "value") expect(subject[writer.to_s]).to eq("value") end end - + shared_examples "a metadata reader" do |reader| it "reads the \"#{reader}\" element" do subject[reader.to_s] = "value" expect(subject.send(reader)).to eq("value") end end - + shared_examples "a metadata reader with an alias" do |reader, aliased_as| it_behaves_like "a metadata reader", reader it "has a reader alias \"#{aliased_as}\"" do subject[reader.to_s] = "value" expect(subject.send(aliased_as)).to eq("value") end end - + shared_examples "a metadata writer with an alias" do |writer, aliased_as| it_behaves_like "a metadata writer", writer it "has a writer alias \"#{aliased_as}\"" do subject.send("#{aliased_as}=", "value") expect(subject.send(writer)).to eq("value") @@ -50,11 +50,11 @@ end shared_examples "a metadata profile accessor with an alias" do |profile, accessor| it_behaves_like "a metadata accessor with an alias", [profile, accessor].join("."), [profile, accessor].join("_") end - + describe "_owner" do it_behaves_like "a metadata reader with an alias", :_owner, :owner end describe "_ownergroup" do it_behaves_like "a metadata reader with an alias", :_ownergroup, :ownergroup @@ -66,11 +66,11 @@ it_behaves_like "a metadata reader with an alias", :_shadowedby, :shadowedby end describe "_datacenter" do it_behaves_like "a metadata reader with an alias", :_datacenter, :datacenter end - + describe "_coowners" do it_behaves_like "a metadata accessor with an alias", :_coowners, :coowners end describe "_target" do it_behaves_like "a metadata accessor with an alias", :_target, :target @@ -82,20 +82,20 @@ it_behaves_like "a metadata accessor with an alias", :_status, :status end describe "_export" do it_behaves_like "a metadata accessor with an alias", :_export, :export end - + describe "_created" do it_behaves_like "a metadata reader", :_created it_behaves_like "a time reader alias", :_created, :created end describe "_updated" do it_behaves_like "a metadata reader", :_updated it_behaves_like "a time reader alias", :_updated, :updated end - + describe "erc" do it_behaves_like "a metadata accessor", :erc end describe "datacite" do it_behaves_like "a metadata accessor", :datacite @@ -104,11 +104,11 @@ it_behaves_like "a metadata accessor", :_crossref end describe "crossref" do it_behaves_like "a metadata accessor", :crossref end - + describe "dc.creator" do it_behaves_like "a metadata profile accessor with an alias", :dc, :creator end describe "dc.title" do it_behaves_like "a metadata profile accessor with an alias", :dc, :title @@ -120,11 +120,11 @@ it_behaves_like "a metadata profile accessor with an alias", :dc, :date end describe "dc.type" do it_behaves_like "a metadata profile accessor with an alias", :dc, :type end - + describe "datacite.creator" do it_behaves_like "a metadata profile accessor with an alias", :datacite, :creator end describe "datacite.title" do it_behaves_like "a metadata profile accessor with an alias", :datacite, :title @@ -136,11 +136,11 @@ it_behaves_like "a metadata profile accessor with an alias", :datacite, :publicationyear end describe "datacite.resourcetype" do it_behaves_like "a metadata profile accessor with an alias", :datacite, :resourcetype end - + describe "erc.who" do it_behaves_like "a metadata profile accessor with an alias", :erc, :who end describe "erc.what" do it_behaves_like "a metadata profile accessor with an alias", :erc, :what @@ -192,12 +192,12 @@ _export: yes _created: 1416507086 _status: public EOS end - it "should treat the string as an ANVL document, splitting into keys and values and unescaping" do - expect(subject.elements).to eq({ "_updated" => "1416507086", + it "treats the string as an ANVL document, splitting into keys and values and unescaping" do + expect(subject).to eq({ "_updated" => "1416507086", "_target" => "http://example.com/path%20with%20spaces", "_profile" => "erc", "_erc" => "who: Proust, Marcel\nwhat: Remembrance of Things Past", "_ownergroup" => "apitest", "_owner" => "apitest", @@ -217,17 +217,17 @@ "_created" => "1416507086", "_status" => "public" } end context "which is a normal Hash" do let(:data) { hsh } - it "should set the metadata elements to the hash" do - expect(subject.elements).to eq(hsh) + it "sets the metadata elements to the hash" do + expect(subject).to eq(hsh) end end context "which is a Metadata instance" do let(:data) { Metadata.new(hsh) } - it "should set the metadata elements to the hash" do - expect(subject.elements).to eq(hsh) + it "sets the metadata elements to the hash" do + expect(subject).to eq(hsh) end end end end