spec/ppl/adapter/vcard/greencard_spec.rb in ppl-1.23.0 vs spec/ppl/adapter/vcard/greencard_spec.rb in ppl-1.24.0

- old
+ new

@@ -17,19 +17,32 @@ @contact.name = "John Doe" @adapter.encode(@contact).should include("FN:John Doe") end it "should encode the contact's email address" do - @contact.email_addresses = ["john@example.org"] + @contact.email_addresses << Ppl::Entity::EmailAddress.new("john@example.org") @adapter.encode(@contact).should include("EMAIL:john@example.org") end + it "should encode the contact's preferred email address as such" do + email_address = Ppl::Entity::EmailAddress.new("john@example.org") + email_address.preferred = true + @contact.email_addresses << email_address + @adapter.encode(@contact).should include("EMAIL;TYPE=pref:john@example.org") + end + it "should encode the contact's phone number" do @contact.phone_numbers << Ppl::Entity::PhoneNumber.new("01234567890") @adapter.encode(@contact).should include("TEL:01234567890") end + it "should encode the contact's preferred phone number as such" do + @contact.phone_numbers << Ppl::Entity::PhoneNumber.new("01234567890") + @contact.phone_numbers[0].preferred = true + @adapter.encode(@contact).should include("TEL;TYPE=pref:01234567890") + end + it "should encode the contact's phone number's type" do @contact.phone_numbers << Ppl::Entity::PhoneNumber.new("01234567890", "cell") @adapter.encode(@contact).should include("TEL;TYPE=cell:01234567890") end @@ -135,13 +148,25 @@ "VERSION:3.0", "EMAIL;TYPE=home:home@example.org", "END:VCARD", ].join("\n") contact = @adapter.decode(vcard) - contact.email_addresses.first.should eq "home@example.org" + contact.email_addresses.first.address.should eq "home@example.org" end + it "should mark preferred email addresses as such" do + vcard = [ + "BEGIN:VCARD", + "N:,test", + "VERSION:3.0", + "EMAIL;PREF:home@example.org", + "END:VCARD", + ].join("\n") + contact = @adapter.decode(vcard) + contact.email_addresses.first.preferred.should eq true + end + it "should decode the contact's phone number" do vcard = [ "BEGIN:VCARD", "N:,test", "VERSION:3.0", @@ -149,9 +174,22 @@ "END:VCARD", ].join("\n") contact = @adapter.decode(vcard) phone_number = contact.phone_numbers.first phone_number.number.should eq "01234567890" + end + + it "should mark preferred phone numbers as such" do + vcard = [ + "BEGIN:VCARD", + "N:,test", + "VERSION:3.0", + "TEL;TYPE=pref:01234567890", + "END:VCARD", + ].join("\n") + contact = @adapter.decode(vcard) + phone_number = contact.phone_numbers.first + phone_number.preferred.should eq true end it "should decode the contact's phone number's type" do vcard = [ "BEGIN:VCARD",