Created
February 26, 2014 12:27
-
-
Save escowles/9228642 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "DamsResource" do | |
describe "MADS accessors" do | |
before do | |
params = { | |
myResource: { | |
topic: "Cosmology", | |
temporal: "16th Century", | |
personalName: { | |
fullName: "Jefferson, Thomas", | |
dateName: "1743-1826" | |
}, | |
personalName: { | |
fullName: "Jefferson, Thomas", | |
dateName: "1743-1826" | |
}, | |
corporateName: { | |
name: "University of California, San Diego.", | |
name: "University Library", | |
}, | |
complexSubject: { | |
personalName: { | |
fullName: "Jeffersion, Thomas", | |
dateName: "1743-1826" | |
}, | |
topic: "Presidency", | |
temporal: "1801-1809" | |
}, | |
} | |
} | |
@resource = DamsResource.new() | |
@resource.update_attributes(params[:myResource]) | |
end | |
it "should support topic, temporal" do | |
# TopicElement | |
@resource.topic.should == ["Cosmology"] | |
# OR ??? @resource.topic.should == ["Cosmology", "Presidency"] ??? | |
# TemporalElement | |
@resource.temporal.should == ["16th Century"] | |
# OR ??? @resource.temporal.should == ["16th Century", "1801-1809"] ??? | |
end | |
describe "personalName" do | |
it "should support MADS.PersonalName structures" do | |
@resource.personalName(0).fullName.should == ["Jefferson, Thomas"] | |
@resource.personalName(0).fullName(0).elementValue.should == "Jefferson, Thomas" | |
@resource.personalName(0).dateName.should == ["1743-1826"] | |
@resource.personalName(1).fullName.should == ["Hemings, Sally"] | |
end | |
it "should aggregate subelement values in authoritativeLabel" do | |
@resource.personalName.should == ["Jefferson, Thomas, 1743-1826", "Hemings, Sally"] | |
@resource.personalName(0).authoritativeLabel.should == "Jefferson, Thomas, 1743-1826" | |
end | |
it "Insertion Operator `<<` when given a String should create a PersonalNameElement and put the string into its FullNameElement" do | |
@resource.personalName << "Jefferson Randolph, Martha" | |
@resource.personalName.should == ["Jefferson, Thomas, 1743-1826", "Hemings, Sally", "Jefferson Randolph, Martha"] | |
@resource.personalName(1).fullName.should == ["Jefferson Randolph, Martha"] | |
end | |
it "Insertion Operator `<<` when given a Node should simply insert it" do | |
new_name = MADS::PersonalName.new(@resource.graph) | |
new_name.fullName = "Callender, James T." | |
new_name.dateName = "1802" | |
@resource.personalName << new_name | |
@resource.personalName(1).authoritativeLabel.should == "Callender, James T., 1802" | |
@resource.personalName(1).fullName.should == ["Callender, James T."] | |
@resource.personalName(1).dateName.should == ["1802"] | |
end | |
it "Insertion Operator `<<` when given a Hash should use update_attributes behavior" do | |
@resource.personalName << {fullName:"Callender, James T.", dateName: "dateName"} | |
@resource.personalName(1).authoritativeLabel.should == "Callender, James T., 1802" | |
@resource.personalName(1).fullName.should == ["Callender, James T."] | |
@resource.personalName(1).dateName.should == ["1802"] | |
end | |
end | |
it "should support MADS.CorporateName structures" do | |
@resource.corporateName.should == ["University of California, San Diego., University Library"] | |
@resource.corporateName(0).fullName.should == ["University of California, San Diego."] | |
@resource.corporateName(0).dateName.should == ["University Library"] | |
end | |
describe "complexSubject" do | |
it "should support MADS.ComplexSubject structures" do | |
@resource.complexSubject(0).personalName.should == ["Jefferson, Thomas, 1743-1826"] | |
@resource.complexSubject(0).topic.should == ["Presidency"] | |
@resource.complexSubject(0).temporal.should == ["1801-1809"] | |
end | |
it "should aggregate subelement values in authoritativeLabel" do | |
@resource.complexSubject.should == ["Jefferson, Thomas, 1743-1826--Presidency--1801-1809"] | |
@resource.complexSubject(0).authoritativeLabel.should == "Jefferson, Thomas, 1743-1826--Presidency--1801-1809" | |
end | |
end | |
it "should create proper XML when stuff has been inserted" do | |
@resource.personalName << "Jefferson Randolph, Martha" | |
@resource.complexSubject << {personalName: "Callender, James T.", topic:"Newspapers"} | |
@resource.content.should be_equivalent_to fixture("damsSubjectExpectedOutput.rdf.xml") | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mads:Topic> | |
<mads:authoritativeLabel>Cosmology</mads:authoritativeLabel> | |
<mads:elementList rdf:parseType="Collection"> | |
<mads:TopicElement> | |
<mads:elementValue>Cosmology</mads:elementValue> | |
</mads:TopicElement> | |
</mads:elementList> | |
</mads:Topic> | |
<mads:Temporal> | |
<mads:authoritativeLabel>16th Century</mads:authoritativeLabel> | |
<mads:elementList rdf:parseType="Collection"> | |
<mads:TemporalElement> | |
<mads:elementValue>16th Century</mads:elementValue> | |
</mads:TemporalElement> | |
</mads:elementList> | |
</mads:Temporal> | |
<mads:PersonalName> | |
<mads:authoritativeLabel>Jefferson, Thomas, 1743-1826</mads:authoritativeLabel> | |
<mads:elementList rdf:parseType="Collection"> | |
<mads:FullNameElement> | |
<mads:elementValue>Jefferson, Thomas,</mads:elementValue> | |
</mads:FullNameElement> | |
<mads:DateNameElement> | |
<mads:elementValue>1743-1826</mads:elementValue> | |
</mads:DateNameElement> | |
</mads:elementList> | |
</mads:PersonalName> | |
<mads:CorporateName> | |
<mads:authoritativeLabel>University of California, San Diego. University Library</mads:authoritativeLabel> | |
<mads:elementList rdf:parseType="Collection"> | |
<mads:NameElement> | |
<mads:elementValue>University of California, San Diego.</mads:elementValue> | |
</mads:NameElement> | |
<mads:NameElement> | |
<mads:elementValue>University Library</mads:elementValue> | |
</mads:NameElement> | |
</mads:elementList> | |
</mads:CorporateName> | |
<mads:ComplexSubject> | |
<mads:authoritativeLabel>Jefferson, Thomas, 1743-1826--Presidency--1801-1809</mads:authortiativeLabel> | |
<mads:componentList rdf:parseType="Collection"> | |
<mads:PersonalName> | |
<mads:authoritativeLabel>Jefferson, Thomas, 1743-1826</mads:authoritativeLabel> | |
<mads:elementList rdf:parseType="Collection"> | |
<mads:FullNameElement> | |
<mads:elementValue>Jefferson, Thomas,</mads:elementValue> | |
</mads:FullNameElement> | |
<mads:DateNameElement> | |
<mads:elementValue>1743-1826</mads:elementValue> | |
</mads:DateNameElement> | |
</mads:elementList> | |
</mads:PersonalName> | |
<mads:Topic> | |
<mads:authoritativeLabel>Presidency</mads:authoritativeLabel> | |
<mads:elementList rdf:parseType="Collection"> | |
<mads:TopicElement> | |
<mads:elementValue>Presidency</mads:elementValue> | |
</mads:TopicElement> | |
</mads:elementList> | |
</mads:Topic> | |
<mads:Temporal> | |
<mads:authoritativeLabel>1801-1809</mads:authoritativeLabel> | |
<mads:elementList rdf:parseType="Collection"> | |
<mads:TemporalElement> | |
<mads:elementValue>1801-1809</mads:elementValue> | |
</mads:TemporalElement> | |
</mads:elementList> | |
</mads:Temporal> | |
</mads:componentList> | |
</mads:ComplexSubject> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment