ppl 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +1 -0
- data/features/step_definitions/ppl_steps.rb +3 -3
- data/ppl.gemspec +1 -1
- data/spec/ppl/adapter/color/colored_spec.rb +3 -3
- data/spec/ppl/adapter/email_scraper/mail_spec.rb +13 -13
- data/spec/ppl/adapter/output_spec.rb +7 -7
- data/spec/ppl/adapter/storage/disk_spec.rb +18 -18
- data/spec/ppl/adapter/storage/factory_spec.rb +3 -3
- data/spec/ppl/adapter/storage/git_spec.rb +31 -31
- data/spec/ppl/adapter/storage_spec.rb +3 -3
- data/spec/ppl/adapter/vcard/greencard_spec.rb +45 -45
- data/spec/ppl/application/bootstrap_spec.rb +128 -128
- data/spec/ppl/application/command_spec.rb +8 -8
- data/spec/ppl/application/command_suite_spec.rb +7 -7
- data/spec/ppl/application/configuration_spec.rb +16 -16
- data/spec/ppl/application/input_spec.rb +2 -2
- data/spec/ppl/application/router_spec.rb +8 -8
- data/spec/ppl/application/shell_spec.rb +39 -39
- data/spec/ppl/command/add_spec.rb +6 -6
- data/spec/ppl/command/age_spec.rb +7 -7
- data/spec/ppl/command/attribute_spec.rb +22 -22
- data/spec/ppl/command/bday_spec.rb +11 -11
- data/spec/ppl/command/completion_spec.rb +7 -7
- data/spec/ppl/command/email_spec.rb +19 -19
- data/spec/ppl/command/external_spec.rb +7 -7
- data/spec/ppl/command/help_spec.rb +15 -15
- data/spec/ppl/command/init_spec.rb +5 -5
- data/spec/ppl/command/ls_spec.rb +12 -12
- data/spec/ppl/command/mutt_spec.rb +33 -33
- data/spec/ppl/command/mv_spec.rb +11 -11
- data/spec/ppl/command/name_spec.rb +17 -17
- data/spec/ppl/command/nick_spec.rb +1 -1
- data/spec/ppl/command/org_spec.rb +1 -1
- data/spec/ppl/command/phone_spec.rb +15 -15
- data/spec/ppl/command/post_spec.rb +29 -29
- data/spec/ppl/command/rm_spec.rb +3 -3
- data/spec/ppl/command/scrape_spec.rb +24 -24
- data/spec/ppl/command/shell_spec.rb +41 -41
- data/spec/ppl/command/show_spec.rb +4 -4
- data/spec/ppl/command/url_spec.rb +1 -1
- data/spec/ppl/command/version_spec.rb +4 -4
- data/spec/ppl/entity/address_book_spec.rb +1 -1
- data/spec/ppl/entity/contact_spec.rb +16 -16
- data/spec/ppl/entity/email_address_spec.rb +3 -3
- data/spec/ppl/entity/name_spec.rb +1 -1
- data/spec/ppl/entity/phone_number_spec.rb +5 -5
- data/spec/ppl/entity/postal_address_spec.rb +2 -2
- data/spec/ppl/format/address_book/ages_spec.rb +3 -3
- data/spec/ppl/format/address_book/birthdays_spec.rb +3 -3
- data/spec/ppl/format/address_book/email_addresses_spec.rb +3 -3
- data/spec/ppl/format/address_book/mutt_query_spec.rb +3 -3
- data/spec/ppl/format/address_book/names_spec.rb +3 -3
- data/spec/ppl/format/address_book/nicknames_spec.rb +4 -4
- data/spec/ppl/format/address_book/one_line_spec.rb +5 -5
- data/spec/ppl/format/address_book/organizations_spec.rb +3 -3
- data/spec/ppl/format/address_book/phone_numbers_spec.rb +3 -3
- data/spec/ppl/format/address_book/postal_addresses_spec.rb +2 -2
- data/spec/ppl/format/address_book/urls_spec.rb +3 -3
- data/spec/ppl/format/contact/age_spec.rb +8 -8
- data/spec/ppl/format/contact/birthday_spec.rb +4 -4
- data/spec/ppl/format/contact/email_addresses_spec.rb +3 -3
- data/spec/ppl/format/contact/full_spec.rb +11 -11
- data/spec/ppl/format/contact/nicknames_spec.rb +4 -4
- data/spec/ppl/format/contact/organization_spec.rb +4 -4
- data/spec/ppl/format/contact/phone_number_spec.rb +4 -4
- data/spec/ppl/format/contact/postal_address_spec.rb +1 -1
- data/spec/ppl/format/contact/postal_addresses_spec.rb +3 -3
- data/spec/ppl/format/contact/urls_spec.rb +4 -4
- data/spec/ppl/format/custom/contact_spec.rb +13 -13
- data/spec/ppl/format/custom/email_address_spec.rb +3 -3
- data/spec/ppl/format/custom/phone_number_spec.rb +4 -4
- data/spec/ppl/format/custom_spec.rb +6 -6
- data/spec/ppl/format/name/full_only_spec.rb +4 -4
- data/spec/ppl/format/postal_address/multi_line_spec.rb +10 -10
- data/spec/ppl/format/postal_address/one_line_spec.rb +9 -9
- data/spec/ppl/format/table_spec.rb +11 -11
- data/spec/ppl/service/email_address_spec.rb +13 -13
- data/spec/ppl/service/name_spec.rb +9 -9
- data/spec/ppl/service/phone_number_spec.rb +11 -11
- data/spec/ppl/service/postal_address_spec.rb +20 -20
- data/spec/spec_helper.rb +3 -0
- metadata +1 -1
@@ -2,7 +2,7 @@ describe Ppl::Format::AddressBook::Organizations do
|
|
2
2
|
describe "#initialize" do
|
3
3
|
it "should pass the colors through to the table" do
|
4
4
|
colors = {"id" => "blue"}
|
5
|
-
Ppl::Format::Table.
|
5
|
+
expect(Ppl::Format::Table).to receive(:new).with([:id, :organizations], colors)
|
6
6
|
format = Ppl::Format::AddressBook::Organizations.new(colors)
|
7
7
|
end
|
8
8
|
end
|
@@ -25,7 +25,7 @@ describe Ppl::Format::AddressBook::Organizations do
|
|
25
25
|
describe "#process" do
|
26
26
|
|
27
27
|
it "should at least show the contact's id" do
|
28
|
-
@table.
|
28
|
+
expect(@table).to receive(:add_row).with({
|
29
29
|
:id => "test:",
|
30
30
|
:organizations => "",
|
31
31
|
})
|
@@ -34,7 +34,7 @@ describe Ppl::Format::AddressBook::Organizations do
|
|
34
34
|
|
35
35
|
it "should show the organization if it's available" do
|
36
36
|
@contact.organizations.push("Example Ltd")
|
37
|
-
@table.
|
37
|
+
expect(@table).to receive(:add_row).with({
|
38
38
|
:id => "test:",
|
39
39
|
:organizations => "Example Ltd",
|
40
40
|
})
|
@@ -2,7 +2,7 @@ describe Ppl::Format::AddressBook::PhoneNumbers do
|
|
2
2
|
describe "#initialize" do
|
3
3
|
it "should pass the colors through to the table" do
|
4
4
|
colors = {"id" => "blue"}
|
5
|
-
Ppl::Format::Table.
|
5
|
+
expect(Ppl::Format::Table).to receive(:new).with([:id, :phone_numbers], colors)
|
6
6
|
format = Ppl::Format::AddressBook::PhoneNumbers.new(colors)
|
7
7
|
end
|
8
8
|
end
|
@@ -25,7 +25,7 @@ describe Ppl::Format::AddressBook::PhoneNumbers do
|
|
25
25
|
describe "#process" do
|
26
26
|
|
27
27
|
it "should at least show the contact's id" do
|
28
|
-
@table.
|
28
|
+
expect(@table).to receive(:add_row).with({
|
29
29
|
:id => "test:",
|
30
30
|
:phone_numbers => "",
|
31
31
|
})
|
@@ -34,7 +34,7 @@ describe Ppl::Format::AddressBook::PhoneNumbers do
|
|
34
34
|
|
35
35
|
it "should show the phone number if it's available" do
|
36
36
|
@contact.phone_numbers << Ppl::Entity::PhoneNumber.new("01234567890")
|
37
|
-
@table.
|
37
|
+
expect(@table).to receive(:add_row).with({
|
38
38
|
:id => "test:",
|
39
39
|
:phone_numbers => "01234567890",
|
40
40
|
})
|
@@ -2,7 +2,7 @@ describe Ppl::Format::AddressBook::PostalAddresses do
|
|
2
2
|
describe "#initialize" do
|
3
3
|
it "should pass the colors through to the table" do
|
4
4
|
colors = {"id" => "blue"}
|
5
|
-
Ppl::Format::Table.
|
5
|
+
expect(Ppl::Format::Table).to receive(:new).with([:id, :address_ids], colors)
|
6
6
|
format = Ppl::Format::AddressBook::PostalAddresses.new(colors)
|
7
7
|
end
|
8
8
|
end
|
@@ -28,7 +28,7 @@ describe Ppl::Format::AddressBook::PostalAddresses do
|
|
28
28
|
describe "#process" do
|
29
29
|
|
30
30
|
it "shows the contact's and address' IDs" do
|
31
|
-
@table.
|
31
|
+
expect(@table).to receive(:add_row).with({
|
32
32
|
:id => "test:",
|
33
33
|
:address_ids => "home",
|
34
34
|
})
|
@@ -2,7 +2,7 @@ describe Ppl::Format::AddressBook::Urls do
|
|
2
2
|
describe "#initialize" do
|
3
3
|
it "should pass the colors through to the table" do
|
4
4
|
colors = {"id" => "blue"}
|
5
|
-
Ppl::Format::Table.
|
5
|
+
expect(Ppl::Format::Table).to receive(:new).with([:id, :urls], colors)
|
6
6
|
format = Ppl::Format::AddressBook::Urls.new(colors)
|
7
7
|
end
|
8
8
|
end
|
@@ -25,7 +25,7 @@ describe Ppl::Format::AddressBook::Urls do
|
|
25
25
|
describe "#process" do
|
26
26
|
|
27
27
|
it "should at least show the contact's id" do
|
28
|
-
@table.
|
28
|
+
expect(@table).to receive(:add_row).with({
|
29
29
|
:id => "test:",
|
30
30
|
:urls => "",
|
31
31
|
})
|
@@ -34,7 +34,7 @@ describe Ppl::Format::AddressBook::Urls do
|
|
34
34
|
|
35
35
|
it "should show a URL if it's available" do
|
36
36
|
@contact.urls.push "http://example.org/~jdoe"
|
37
|
-
@table.
|
37
|
+
expect(@table).to receive(:add_row).with({
|
38
38
|
:id => "test:",
|
39
39
|
:urls => "http://example.org/~jdoe",
|
40
40
|
})
|
@@ -10,21 +10,21 @@ describe Ppl::Format::Contact::Age do
|
|
10
10
|
describe "#process" do
|
11
11
|
|
12
12
|
it "should return an empty string if the contact lacks a birth date" do
|
13
|
-
@color.
|
14
|
-
@contact.
|
15
|
-
@format.process(@contact).
|
13
|
+
allow(@color).to receive(:colorize)
|
14
|
+
expect(@contact).to receive(:age).and_return(nil)
|
15
|
+
expect(@format.process(@contact)).to eq ""
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return the contact's age if the birthdate is known" do
|
19
|
-
@contact.
|
20
|
-
@format.process(@contact).
|
19
|
+
expect(@contact).to receive(:age).and_return(10)
|
20
|
+
expect(@format.process(@contact)).to eq "10"
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should colorize the string if configured to do so" do
|
24
|
-
@contact.
|
24
|
+
expect(@contact).to receive(:age).and_return(10)
|
25
25
|
@format.colors = { "age" => "blue" }
|
26
|
-
@color.
|
27
|
-
@format.process(@contact).
|
26
|
+
expect(@color).to receive(:colorize).and_return("age in blue")
|
27
|
+
expect(@format.process(@contact)).to eq "age in blue"
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
@@ -10,18 +10,18 @@ describe Ppl::Format::Contact::Birthday do
|
|
10
10
|
describe "#process" do
|
11
11
|
|
12
12
|
it "should return an empty string if the contact lacks a birthday" do
|
13
|
-
@format.process(Ppl::Entity::Contact.new).
|
13
|
+
expect(@format.process(Ppl::Entity::Contact.new)).to eq ""
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return the contact's birthday if it is set" do
|
17
17
|
@contact.birthday = Date.parse("1970-01-01")
|
18
|
-
@format.process(@contact).
|
18
|
+
expect(@format.process(@contact)).to eq "1970-01-01"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should colorize the string if configured to do so" do
|
22
22
|
@format.colors = { "birthday" => "blue" }
|
23
|
-
@color.
|
24
|
-
@format.process(@contact).
|
23
|
+
expect(@color).to receive(:colorize).and_return("birthday in blue")
|
24
|
+
expect(@format.process(@contact)).to eq "birthday in blue"
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -2,7 +2,7 @@ describe Ppl::Format::Contact::EmailAddresses do
|
|
2
2
|
describe "#initialize" do
|
3
3
|
it "should pass the colors through to the table" do
|
4
4
|
colors = {"id" => "blue"}
|
5
|
-
Ppl::Format::Table.
|
5
|
+
expect(Ppl::Format::Table).to receive(:new).with([:star, :email_addresses], colors)
|
6
6
|
format = Ppl::Format::Contact::EmailAddresses.new(colors)
|
7
7
|
end
|
8
8
|
end
|
@@ -22,7 +22,7 @@ describe Ppl::Format::Contact::EmailAddresses do
|
|
22
22
|
describe "#process" do
|
23
23
|
|
24
24
|
it "should pass each email address to the table" do
|
25
|
-
@table.
|
25
|
+
expect(@table).to receive(:add_row).with({
|
26
26
|
:star => " ",
|
27
27
|
:email_addresses => "test@example.org",
|
28
28
|
})
|
@@ -31,7 +31,7 @@ describe Ppl::Format::Contact::EmailAddresses do
|
|
31
31
|
|
32
32
|
it "should mark the preferred email with a star" do
|
33
33
|
@email.preferred = true
|
34
|
-
@table.
|
34
|
+
expect(@table).to receive(:add_row).with({
|
35
35
|
:star => "*",
|
36
36
|
:email_addresses => "test@example.org",
|
37
37
|
})
|
@@ -12,26 +12,26 @@ describe Ppl::Format::Contact::Full do
|
|
12
12
|
@format.phone_number_format = @phone_number_format
|
13
13
|
@format.postal_address_format = @postal_address_format
|
14
14
|
|
15
|
-
@email_address_format.
|
15
|
+
allow(@email_address_format).to receive(:process)
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#process" do
|
19
19
|
|
20
20
|
it "should return an empty string if the contact lacks any properties" do
|
21
|
-
@format.process(Ppl::Entity::Contact.new).
|
21
|
+
expect(@format.process(Ppl::Entity::Contact.new)).to eq ""
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should start with the contact's name" do
|
25
25
|
@contact.name = Ppl::Entity::Name.new
|
26
26
|
@contact.name.full = "John Doe"
|
27
|
-
@format.process(@contact).
|
27
|
+
expect(@format.process(@contact)).to eq "John Doe"
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should include their email address in brackets" do
|
31
31
|
@contact.name = Ppl::Entity::Name.new
|
32
32
|
@contact.name.full = "John Doe"
|
33
33
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("john@example.org")
|
34
|
-
@format.process(@contact).
|
34
|
+
expect(@format.process(@contact)).to include "John Doe <john@example.org>"
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should include their preferred email address in brackets" do
|
@@ -40,40 +40,40 @@ describe Ppl::Format::Contact::Full do
|
|
40
40
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("john@example.org")
|
41
41
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("fred@testtest.es")
|
42
42
|
@contact.email_addresses[1].preferred = true
|
43
|
-
@format.process(@contact).
|
43
|
+
expect(@format.process(@contact)).to include "John Doe <fred@testtest.es>"
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should invoke the email address formatter if there are any addresses" do
|
47
47
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("john@example.net")
|
48
|
-
@email_address_format.
|
48
|
+
expect(@email_address_format).to receive(:process).with(@contact)
|
49
49
|
@format.process(@contact)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should invoke the phone number formatter if there are any numbers" do
|
53
53
|
@contact.phone_numbers << Ppl::Entity::PhoneNumber.new("01234567890")
|
54
|
-
@phone_number_format.
|
54
|
+
expect(@phone_number_format).to receive(:process).with(@contact)
|
55
55
|
@format.process(@contact)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should show their birthday if available" do
|
59
59
|
@contact.birthday = Date.parse("1980-01-01")
|
60
|
-
@format.process(@contact).
|
60
|
+
expect(@format.process(@contact)).to include "1980-01-01"
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should show all their organizations" do
|
64
64
|
@contact.organizations.push("Example Ltd")
|
65
|
-
@format.process(@contact).
|
65
|
+
expect(@format.process(@contact)).to include "Example Ltd"
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should show their postal address if available" do
|
69
69
|
@contact.postal_addresses << @address
|
70
|
-
@postal_address_format.
|
70
|
+
expect(@postal_address_format).to receive(:process).and_return("")
|
71
71
|
@format.process(@contact)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should show all their URLs" do
|
75
75
|
@contact.urls.push "http://example.org"
|
76
|
-
@format.process(@contact).
|
76
|
+
expect(@format.process(@contact)).to include "http://example.org"
|
77
77
|
end
|
78
78
|
|
79
79
|
end
|
@@ -10,18 +10,18 @@ describe Ppl::Format::Contact::Nicknames do
|
|
10
10
|
describe "#process" do
|
11
11
|
|
12
12
|
it "should return an empty string if the contact lacks a nickname" do
|
13
|
-
@format.process(Ppl::Entity::Contact.new).
|
13
|
+
expect(@format.process(Ppl::Entity::Contact.new)).to eq ""
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return the contact's nickname if one is set" do
|
17
17
|
@contact.nicknames.push("Dopey")
|
18
|
-
@format.process(@contact).
|
18
|
+
expect(@format.process(@contact)).to eq "Dopey"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should colorize the string if configured to do so" do
|
22
22
|
@format.colors = { "nicknames" => "blue" }
|
23
|
-
@color.
|
24
|
-
@format.process(@contact).
|
23
|
+
expect(@color).to receive(:colorize).and_return("nicknames in blue")
|
24
|
+
expect(@format.process(@contact)).to eq "nicknames in blue"
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -10,18 +10,18 @@ describe Ppl::Format::Contact::Organization do
|
|
10
10
|
describe "#process" do
|
11
11
|
|
12
12
|
it "should return an empty string if the contact lacks an organization" do
|
13
|
-
@format.process(Ppl::Entity::Contact.new).
|
13
|
+
expect(@format.process(Ppl::Entity::Contact.new)).to eq ""
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return the contact's organization if it is set" do
|
17
17
|
@contact.organizations.push("Example Ltd")
|
18
|
-
@format.process(@contact).
|
18
|
+
expect(@format.process(@contact)).to eq "Example Ltd"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should colorize the string if configured to do so" do
|
22
22
|
@format.colors = { "organizations" => "blue" }
|
23
|
-
@color.
|
24
|
-
@format.process(@contact).
|
23
|
+
expect(@color).to receive(:colorize).and_return("organizations in blue")
|
24
|
+
expect(@format.process(@contact)).to eq "organizations in blue"
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -3,7 +3,7 @@ describe Ppl::Format::Contact::PhoneNumber do
|
|
3
3
|
describe "#initialize" do
|
4
4
|
it "should pass the colors through to the table" do
|
5
5
|
colors = {"number" => "blue"}
|
6
|
-
Ppl::Format::Table.
|
6
|
+
expect(Ppl::Format::Table).to receive(:new).with([:star, :phone_numbers, :type], colors)
|
7
7
|
format = Ppl::Format::Contact::PhoneNumber.new(colors)
|
8
8
|
end
|
9
9
|
end
|
@@ -20,7 +20,7 @@ describe Ppl::Format::Contact::PhoneNumber do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should always include the phone number" do
|
23
|
-
@table.
|
23
|
+
expect(@table).to receive(:add_row).with({
|
24
24
|
:star => " ",
|
25
25
|
:phone_numbers => "01234567890",
|
26
26
|
:type => nil,
|
@@ -30,7 +30,7 @@ describe Ppl::Format::Contact::PhoneNumber do
|
|
30
30
|
|
31
31
|
it "should put the type in parentheses" do
|
32
32
|
@number.type = "work"
|
33
|
-
@table.
|
33
|
+
expect(@table).to receive(:add_row).with({
|
34
34
|
:star => " ",
|
35
35
|
:phone_numbers => "01234567890",
|
36
36
|
:type => "(work)",
|
@@ -40,7 +40,7 @@ describe Ppl::Format::Contact::PhoneNumber do
|
|
40
40
|
|
41
41
|
it "should mark preferred numbers with a star" do
|
42
42
|
@number.preferred = true
|
43
|
-
@table.
|
43
|
+
expect(@table).to receive(:add_row).with({
|
44
44
|
:star => "*",
|
45
45
|
:phone_numbers => "01234567890",
|
46
46
|
:type => nil,
|
@@ -13,7 +13,7 @@ describe Ppl::Format::Contact::PostalAddress do
|
|
13
13
|
|
14
14
|
it "should return the contact's street address if it is set" do
|
15
15
|
@address.street = "1 Test Road"
|
16
|
-
@table.
|
16
|
+
expect(@table).to receive(:add_row).with({
|
17
17
|
:label => "Street:",
|
18
18
|
:value => "1 Test Road",
|
19
19
|
})
|
@@ -2,7 +2,7 @@ describe Ppl::Format::Contact::PostalAddresses do
|
|
2
2
|
describe "#initialize" do
|
3
3
|
it "should pass the colors through to the table" do
|
4
4
|
colors = {"address_id" => "blue"}
|
5
|
-
Ppl::Format::Table.
|
5
|
+
expect(Ppl::Format::Table).to receive(:new).with([:star, :address_id, :address_text], colors)
|
6
6
|
format = Ppl::Format::Contact::PostalAddresses.new(colors)
|
7
7
|
end
|
8
8
|
end
|
@@ -24,8 +24,8 @@ describe Ppl::Format::Contact::PostalAddresses do
|
|
24
24
|
|
25
25
|
it "passes each postal address to the postal address formatter" do
|
26
26
|
@contact.postal_addresses << @address
|
27
|
-
@pa_fmt.
|
28
|
-
@table.
|
27
|
+
expect(@pa_fmt).to receive(:process).with(@address, @table)
|
28
|
+
expect(@table).to receive(:to_s)
|
29
29
|
@format.process(@contact)
|
30
30
|
end
|
31
31
|
|
@@ -10,18 +10,18 @@ describe Ppl::Format::Contact::Urls do
|
|
10
10
|
describe "#process" do
|
11
11
|
|
12
12
|
it "should return an empty string if the contact lacks a URL" do
|
13
|
-
@format.process(Ppl::Entity::Contact.new).
|
13
|
+
expect(@format.process(Ppl::Entity::Contact.new)).to eq ""
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return the contact's URL if one is set" do
|
17
17
|
@contact.urls.push "http://example.org/~jdoe"
|
18
|
-
@format.process(@contact).
|
18
|
+
expect(@format.process(@contact)).to eq "http://example.org/~jdoe"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should colorize the string if configured to do so" do
|
22
22
|
@format.colors = { "urls" => "blue" }
|
23
|
-
@color.
|
24
|
-
@format.process(@contact).
|
23
|
+
expect(@color).to receive(:colorize).and_return("urls in blue")
|
24
|
+
expect(@format.process(@contact)).to eq "urls in blue"
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -8,7 +8,7 @@ describe Ppl::Format::Custom::Contact do
|
|
8
8
|
describe "%n" do
|
9
9
|
it "should be replaced with a newlines" do
|
10
10
|
@format.format = "%n"
|
11
|
-
@format.process(@contact).
|
11
|
+
expect(@format.process(@contact)).to eq "\n"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -16,7 +16,7 @@ describe Ppl::Format::Custom::Contact do
|
|
16
16
|
it "should output the contact's ID" do
|
17
17
|
@contact.id = "test"
|
18
18
|
@format.format = "%i"
|
19
|
-
@format.process(@contact).
|
19
|
+
expect(@format.process(@contact)).to eq "test"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -24,7 +24,7 @@ describe Ppl::Format::Custom::Contact do
|
|
24
24
|
it "should output the contact's name" do
|
25
25
|
@contact.name = "John Doe"
|
26
26
|
@format.format = "%N"
|
27
|
-
@format.process(@contact).
|
27
|
+
expect(@format.process(@contact)).to eq "John Doe"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -32,16 +32,16 @@ describe Ppl::Format::Custom::Contact do
|
|
32
32
|
it "should output the contact's nickname" do
|
33
33
|
@contact.nicknames << "Johnny"
|
34
34
|
@format.format = "%k"
|
35
|
-
@format.process(@contact).
|
35
|
+
expect(@format.process(@contact)).to eq "Johnny"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "%a" do
|
40
40
|
it "should output the contact's age" do
|
41
41
|
@contact.birthday = Date.parse("2000-01-01")
|
42
|
-
Date.
|
42
|
+
allow(Date).to receive(:today).and_return(Date.parse("2010-01-02"))
|
43
43
|
@format.format = "%a"
|
44
|
-
@format.process(@contact).
|
44
|
+
expect(@format.process(@contact)).to eq "10"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -49,12 +49,12 @@ describe Ppl::Format::Custom::Contact do
|
|
49
49
|
it "should output the contact's birthday" do
|
50
50
|
@contact.birthday = Date.parse("1985-06-07")
|
51
51
|
@format.format = "%b"
|
52
|
-
@format.process(@contact).
|
52
|
+
expect(@format.process(@contact)).to eq "1985-06-07"
|
53
53
|
end
|
54
54
|
it "should cause no errors if there's no birthday" do
|
55
55
|
@contact.birthday = nil
|
56
56
|
@format.format = "%b"
|
57
|
-
@format.process(@contact).
|
57
|
+
expect(@format.process(@contact)).to eq ""
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -65,11 +65,11 @@ describe Ppl::Format::Custom::Contact do
|
|
65
65
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("b@example.org")
|
66
66
|
end
|
67
67
|
it "should output the first email address" do
|
68
|
-
@format.process(@contact).
|
68
|
+
expect(@format.process(@contact)).to eq "a@example.org"
|
69
69
|
end
|
70
70
|
it "should output the preferred email address" do
|
71
71
|
@contact.email_addresses[1].preferred = true
|
72
|
-
@format.process(@contact).
|
72
|
+
expect(@format.process(@contact)).to eq "b@example.org"
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -80,11 +80,11 @@ describe Ppl::Format::Custom::Contact do
|
|
80
80
|
@contact.phone_numbers << Ppl::Entity::PhoneNumber.new("1098765432")
|
81
81
|
end
|
82
82
|
it "should output the first phone number" do
|
83
|
-
@format.process(@contact).
|
83
|
+
expect(@format.process(@contact)).to eq "0123456789"
|
84
84
|
end
|
85
85
|
it "should output the preferred phone number" do
|
86
86
|
@contact.phone_numbers[1].preferred = true
|
87
|
-
@format.process(@contact).
|
87
|
+
expect(@format.process(@contact)).to eq "1098765432"
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -92,7 +92,7 @@ describe Ppl::Format::Custom::Contact do
|
|
92
92
|
it "should output the contact's organization" do
|
93
93
|
@contact.organizations << "WTF Inc"
|
94
94
|
@format.format = "%o"
|
95
|
-
@format.process(@contact).
|
95
|
+
expect(@format.process(@contact)).to eq "WTF Inc"
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|