require 'spec_helper' module GutenbergRdf class Rdf describe Agent do let(:agent) do xml = ' 1830 1905 Doe, Jon James Doe, Jon Doe, J. J. ' rdf = REXML::Document.new(xml) Agent.new(rdf.root) end it "expects an agent ID" do expect(agent.id).to eql '402' end it "expects the last name" do expect(agent.lastname).to eql 'Doe' end it "expects the first name(s)" do expect(agent.firstname).to eql 'Jon James' end it "expects the full name" do expect(agent.fullname).to eql 'Jon James Doe' end it "expects a birth date" do expect(agent.birthdate).to eql '1830' end it "expects a death date" do expect(agent.deathdate).to eql '1905' end it "expects a webpage" do expect(agent.webpage).to eql 'http://en.wikipedia.org/wiki/Jon_James_Doe' end it "expects any alias names" do expect(agent.aliases[0]).to eql 'Doe, Jon' expect(agent.aliases[1]).to eql 'Doe, J. J.' end context "when only a single name is given" do let(:agent) do xml = ' Dato ' rdf = REXML::Document.new(xml) Agent.new(rdf.root) end it "expects it to be assigned to the last name" do expect(agent.lastname).to eql 'Dato' end it "expects firstname to be an empty string" do expect(agent.firstname).to eql '' end end context "when the name has a suffix" do let(:agent) do xml = ' Doe, Jon, Sir ' rdf = REXML::Document.new(xml) Agent.new(rdf.root) end it "expects the correct name order" do expect(agent.firstname).to eql 'Sir Jon' expect(agent.lastname).to eql 'Doe' end end context "when full name is given in (brackets)" do let(:agent) do xml = ' Doe, J. J. (Jon James) ' rdf = REXML::Document.new(xml) Agent.new(rdf.root) end it "expects initials to replaced by name in brackets" do pending "Not yet implemented" expect(agent.firstname).to eql 'Jon James' expect(agent.lastname).to eql 'Doe' end it "expects the name (excluding name in brackets) to be added to the aliases" it "should not have duplicate aliases" end end end end