spec/ppl/adapter/vcard/greencard_spec.rb in ppl-2.0.0 vs spec/ppl/adapter/vcard/greencard_spec.rb in ppl-2.1.0

- old
+ new

@@ -3,23 +3,49 @@ describe Ppl::Adapter::Vcard::GreenCard, "#encode" do before(:each) do @adapter = Ppl::Adapter::Vcard::GreenCard.new @contact = Ppl::Entity::Contact.new + @contact.name = Ppl::Entity::Name.new @contact.id = "test" end it "should encode the contact's birthday" do @contact.birthday = Date.parse "2000-01-01" @adapter.encode(@contact).should include("BDAY:20000101") end - it "should encode the contact's name" do - @contact.name = "John Doe" + it "should encode the contact's full name" do + @contact.name.full = "John Doe" @adapter.encode(@contact).should include("FN:John Doe") end + it "should encode the contact's given name" do + @contact.name.given = "John" + @adapter.encode(@contact).should include("N:;John;;;") + end + + it "should encode the contact's family name" do + @contact.name.family = "Smith" + @adapter.encode(@contact).should include("N:Smith;;;;") + end + + it "should encode the contact's middle name" do + @contact.name.middle = "Quentin" + @adapter.encode(@contact).should include("N:;;Quentin;;") + end + + it "should encode the contact's name prefix" do + @contact.name.prefix = "Mr." + @adapter.encode(@contact).should include("N:;;;Mr.;") + end + + it "should encode the contact's name suffix" do + @contact.name.suffix = "BSc" + @adapter.encode(@contact).should include("N:;;;;BSc") + end + it "should encode the contact's email address" do @contact.email_addresses << Ppl::Entity::EmailAddress.new("john@example.org") @adapter.encode(@contact).should include("EMAIL:john@example.org") end @@ -149,11 +175,11 @@ "FN:John Doe", "END:VCARD", ].join("\n") contact = @adapter.decode(vcard) - contact.name.should eq "John Doe" + contact.name.full.should eq "John Doe" end it "should decode the contact's email address" do vcard = [ "BEGIN:VCARD", @@ -385,10 +411,10 @@ "N:;Straße;;;", "FN:Straße", "END:VCARD", ].join("\n") contact = @adapter.decode(vcard) - contact.name.should eq "Straße" + contact.name.full.should eq "Straße" end end