spec/ppl/adapter/vcard/vpim_spec.rb in ppl-1.1.0 vs spec/ppl/adapter/vcard/vpim_spec.rb in ppl-1.2.0

- old
+ new

@@ -30,10 +30,46 @@ it "should encode the contact's organization" do @contact.organization = "Example Ltd" @adapter.encode(@contact).should include("ORG:Example Ltd") end + it "should encode the contact's street address" do + @contact.postal_address = Ppl::Entity::PostalAddress.new + @contact.postal_address.street = "1 Testing Road" + @adapter.encode(@contact).should include("ADR:;;1 Testing Road;;;;") + end + + it "should encode the contact's postal code" do + @contact.postal_address = Ppl::Entity::PostalAddress.new + @contact.postal_address.postal_code = "L7 8AA" + @adapter.encode(@contact).should include("ADR:;;;;;L7 8AA;") + end + + it "should encode the contact's po box" do + @contact.postal_address = Ppl::Entity::PostalAddress.new + @contact.postal_address.po_box = "123456" + @adapter.encode(@contact).should include("ADR:123456;;;;;;") + end + + it "should encode the contact's locality" do + @contact.postal_address = Ppl::Entity::PostalAddress.new + @contact.postal_address.locality = "Liverpool" + @adapter.encode(@contact).should include("ADR:;;;Liverpool;;;") + end + + it "should encode the contact's country" do + @contact.postal_address = Ppl::Entity::PostalAddress.new + @contact.postal_address.country = "UK" + @adapter.encode(@contact).should include("ADR:;;;;;;UK") + end + + it "should encode the contact's region" do + @contact.postal_address = Ppl::Entity::PostalAddress.new + @contact.postal_address.region = "South West" + @adapter.encode(@contact).should include("ADR:;;;;South West;;") + end + end describe Ppl::Adapter::Vcard::Vpim, "#decode" do @@ -108,9 +144,81 @@ "ORG:Example Ltd", "END:VCARD", ].join("\n") contact = @adapter.decode(vcard) contact.organization.should eq "Example Ltd" + end + + it "should decode the contact's street address" do + vcard = [ + "BEGIN:VCARD", + "N:,test", + "VERSION:3.0", + "ADR:;;1 Testing Road;;;;", + "END:VCARD", + ].join("\n") + contact = @adapter.decode(vcard) + contact.postal_address.street.should eq "1 Testing Road" + end + + it "should decode the contact's postal code" do + vcard = [ + "BEGIN:VCARD", + "N:,test", + "VERSION:3.0", + "ADR:;;;;;L7 8AA;", + "END:VCARD", + ].join("\n") + contact = @adapter.decode(vcard) + contact.postal_address.postal_code.should eq "L7 8AA" + end + + it "should decode the contact's po box" do + vcard = [ + "BEGIN:VCARD", + "N:,test", + "VERSION:3.0", + "ADR:123456;;;;;;", + "END:VCARD", + ].join("\n") + contact = @adapter.decode(vcard) + contact.postal_address.po_box.should eq "123456" + end + + it "should decode the contact's locality" do + vcard = [ + "BEGIN:VCARD", + "N:,test", + "VERSION:3.0", + "ADR:;;;Liverpool;;;", + "END:VCARD", + ].join("\n") + contact = @adapter.decode(vcard) + contact.postal_address.locality.should eq "Liverpool" + end + + it "should decode the contact's region" do + vcard = [ + "BEGIN:VCARD", + "N:,test", + "VERSION:3.0", + "ADR:;;;;South West;;", + "END:VCARD", + ].join("\n") + contact = @adapter.decode(vcard) + contact.postal_address.region.should eq "South West" + end + + it "should decode the contact's country" do + vcard = [ + "BEGIN:VCARD", + "N:,test", + "VERSION:3.0", + "ADR:;;;;;;UK", + "END:VCARD", + ].join("\n") + contact = @adapter.decode(vcard) + contact.postal_address.country.should eq "UK" end end