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
@@ -9,7 +9,7 @@ describe Ppl::Format::Custom::EmailAddress do
|
|
9
9
|
it "should output the address" do
|
10
10
|
@address.address = "test@example.org"
|
11
11
|
@format.format = "<%a>"
|
12
|
-
@format.process(@address).
|
12
|
+
expect(@format.process(@address)).to eq "<test@example.org>"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -19,11 +19,11 @@ describe Ppl::Format::Custom::EmailAddress do
|
|
19
19
|
end
|
20
20
|
it "should output a star if the address is preferred" do
|
21
21
|
@address.preferred = true
|
22
|
-
@format.process(@address).
|
22
|
+
expect(@format.process(@address)).to eq "*"
|
23
23
|
end
|
24
24
|
it "should output nothing if the address is not preferred" do
|
25
25
|
@address.preferred = false
|
26
|
-
@format.process(@address).
|
26
|
+
expect(@format.process(@address)).to eq ""
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -9,7 +9,7 @@ describe Ppl::Format::Custom::PhoneNumber do
|
|
9
9
|
it "should output the number itself" do
|
10
10
|
@number.number = "1234567890"
|
11
11
|
@format.format = "tel: %n"
|
12
|
-
@format.process(@number).
|
12
|
+
expect(@format.process(@number)).to eq "tel: 1234567890"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,7 @@ describe Ppl::Format::Custom::PhoneNumber do
|
|
17
17
|
it "should output the type of the number" do
|
18
18
|
@number.type = "cell"
|
19
19
|
@format.format = "(%t)"
|
20
|
-
@format.process(@number).
|
20
|
+
expect(@format.process(@number)).to eq "(cell)"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -27,11 +27,11 @@ describe Ppl::Format::Custom::PhoneNumber do
|
|
27
27
|
end
|
28
28
|
it "should output a star if the number is preferred" do
|
29
29
|
@number.preferred = true
|
30
|
-
@format.process(@number).
|
30
|
+
expect(@format.process(@number)).to eq "*"
|
31
31
|
end
|
32
32
|
it "should output nothing if the number is not preferred" do
|
33
33
|
@number.preferred = false
|
34
|
-
@format.process(@number).
|
34
|
+
expect(@format.process(@number)).to eq ""
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -8,13 +8,13 @@ describe "Ppl::Format::Custom" do
|
|
8
8
|
|
9
9
|
describe "::process" do
|
10
10
|
it "should use the block passed to ::format to process the object" do
|
11
|
-
Ppl::Format::Custom::process(:N, {:name => "jdoe"}).
|
11
|
+
expect(Ppl::Format::Custom::process(:N, {:name => "jdoe"})).to eq "jdoe"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#initialize" do
|
16
16
|
it "should accept a format string" do
|
17
|
-
Ppl::Format::Custom.new("%N").format.
|
17
|
+
expect(Ppl::Format::Custom.new("%N").format).to eq "%N"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,17 +22,17 @@ describe "Ppl::Format::Custom" do
|
|
22
22
|
it "should convert the given object into a string based on the format" do
|
23
23
|
custom = Ppl::Format::Custom.new("%N %N %N")
|
24
24
|
object = { :name => "jdoe" }
|
25
|
-
custom.process(object).
|
25
|
+
expect(custom.process(object)).to eq "jdoe jdoe jdoe"
|
26
26
|
end
|
27
27
|
it "should pad with leading spaces if a positive width is given" do
|
28
28
|
custom = Ppl::Format::Custom.new("%10N")
|
29
29
|
object = { :name => "jdoe" }
|
30
|
-
custom.process(object).
|
30
|
+
expect(custom.process(object)).to eq " jdoe"
|
31
31
|
end
|
32
32
|
it "should pad with trailing spaces if a negative width is given" do
|
33
33
|
custom = Ppl::Format::Custom.new("%-10N")
|
34
34
|
object = { :name => "jdoe" }
|
35
|
-
custom.process(object).
|
35
|
+
expect(custom.process(object)).to eq "jdoe "
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -41,7 +41,7 @@ describe "Ppl::Format::Custom" do
|
|
41
41
|
custom = Ppl::Format::Custom.new
|
42
42
|
custom.preset_formats = { "example" => "%N (%N)" }
|
43
43
|
custom.use_preset "example"
|
44
|
-
custom.process({:name => "a"}).
|
44
|
+
expect(custom.process({:name => "a"})).to eq "a (a)"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -10,18 +10,18 @@ describe Ppl::Format::Name::FullOnly do
|
|
10
10
|
describe "#process" do
|
11
11
|
|
12
12
|
it "should return an empty string if the contact lacks a name" do
|
13
|
-
@format.process(@name).
|
13
|
+
expect(@format.process(@name)).to eq ""
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return just the full name" do
|
17
17
|
@name.full = "John Doe"
|
18
|
-
@format.process(@name).
|
18
|
+
expect(@format.process(@name)).to eq "John Doe"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should colorize the string if configured to do so" do
|
22
22
|
@format.colors = { "name" => "blue" }
|
23
|
-
@color.
|
24
|
-
@format.process(@name).
|
23
|
+
expect(@color).to receive(:colorize).and_return("name in blue")
|
24
|
+
expect(@format.process(@name)).to eq "name in blue"
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -21,12 +21,12 @@ describe Ppl::Format::PostalAddress::MultiLine do
|
|
21
21
|
|
22
22
|
it "outputs each address attribute on its own line" do
|
23
23
|
@lines = @format.process(@address).split "\n"
|
24
|
-
@lines[0].
|
25
|
-
@lines[1].
|
26
|
-
@lines[2].
|
27
|
-
@lines[3].
|
28
|
-
@lines[4].
|
29
|
-
@lines[5].
|
24
|
+
expect(@lines[0]).to eq "123 Happy Lane"
|
25
|
+
expect(@lines[1]).to eq "Bristol"
|
26
|
+
expect(@lines[2]).to eq "A very nice region indeed"
|
27
|
+
expect(@lines[3]).to eq "United Kingdom"
|
28
|
+
expect(@lines[4]).to eq "12345"
|
29
|
+
expect(@lines[5]).to eq "BS1 1SB"
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
@@ -42,10 +42,10 @@ describe Ppl::Format::PostalAddress::MultiLine do
|
|
42
42
|
|
43
43
|
it "doesn't output superfluous blank lines" do
|
44
44
|
@lines = @format.process(@address).split "\n"
|
45
|
-
@lines.length.
|
46
|
-
@lines[0].
|
47
|
-
@lines[1].
|
48
|
-
@lines[2].
|
45
|
+
expect(@lines.length).to eq 3
|
46
|
+
expect(@lines[0]).to eq "123 Happy Lane"
|
47
|
+
expect(@lines[1]).to eq "Bristol"
|
48
|
+
expect(@lines[2]).to eq "United Kingdom"
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
@@ -19,35 +19,35 @@ describe Ppl::Format::PostalAddress::OneLine do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "inserts a blank 'star' column" do
|
22
|
-
@table.
|
22
|
+
expect(@table).to receive(:add_row) { |r| expect(r[:star]).to eq " " }
|
23
23
|
end
|
24
24
|
|
25
25
|
it "marks preferred addresses with a star" do
|
26
26
|
@address.preferred = true
|
27
|
-
@table.
|
27
|
+
expect(@table).to receive(:add_row) { |r| expect(r[:star]).to eq "*" }
|
28
28
|
end
|
29
29
|
|
30
30
|
it "puts the ID in its own column" do
|
31
|
-
@table.
|
31
|
+
expect(@table).to receive(:add_row) { |r| expect(r[:address_id]).to eq "home" }
|
32
32
|
end
|
33
33
|
|
34
34
|
it "concatenates the rest of the address in its own column" do
|
35
35
|
@address.country = nil
|
36
|
-
@table.
|
37
|
-
row[:address_text].
|
36
|
+
expect(@table).to receive(:add_row) do |row|
|
37
|
+
expect(row[:address_text]).to eq "123 Happy Lane"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
it "separates address elements with commas" do
|
42
|
-
@table.
|
43
|
-
row[:address_text].
|
42
|
+
expect(@table).to receive(:add_row) do |row|
|
43
|
+
expect(row[:address_text]).to eq "123 Happy Lane, United Kingdom"
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
it "prunes elements that are empty" do
|
48
48
|
@address.country = ""
|
49
|
-
@table.
|
50
|
-
row[:address_text].
|
49
|
+
expect(@table).to receive(:add_row) do |row|
|
50
|
+
expect(row[:address_text]).to eq "123 Happy Lane"
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -9,7 +9,7 @@ describe Ppl::Format::Table do
|
|
9
9
|
:name,
|
10
10
|
:email,
|
11
11
|
])
|
12
|
-
@table.columns.length.
|
12
|
+
expect(@table.columns.length).to eq 3
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -27,7 +27,7 @@ describe Ppl::Format::Table do
|
|
27
27
|
|
28
28
|
describe "#colors" do
|
29
29
|
it "should be a hash" do
|
30
|
-
@table.colors.
|
30
|
+
expect(@table.colors).to be_a(Hash)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -38,14 +38,14 @@ describe Ppl::Format::Table do
|
|
38
38
|
:name => "John Doe",
|
39
39
|
:email => "jdoe@example.org",
|
40
40
|
})
|
41
|
-
@table.rows.length.
|
41
|
+
expect(@table.rows.length).to eq 1
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "#to_s" do
|
46
46
|
|
47
47
|
it "should return an empty string if the table is empty" do
|
48
|
-
@table.to_s.
|
48
|
+
expect(@table.to_s).to eq ""
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should return a string represenation of its rows" do
|
@@ -54,7 +54,7 @@ describe Ppl::Format::Table do
|
|
54
54
|
:name => "John Doe",
|
55
55
|
:email => "jdoe@example.org",
|
56
56
|
})
|
57
|
-
@table.to_s.
|
57
|
+
expect(@table.to_s).to eq "12345 John Doe jdoe@example.org"
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should use tabs if requested" do
|
@@ -64,7 +64,7 @@ describe Ppl::Format::Table do
|
|
64
64
|
:email => "jdoe@example.org",
|
65
65
|
})
|
66
66
|
@table.separator = Ppl::Format::Table::SEPARATOR_TABS
|
67
|
-
@table.to_s.
|
67
|
+
expect(@table.to_s).to eq "12345\tJohn Doe\tjdoe@example.org"
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should colorize columns if requested" do
|
@@ -78,7 +78,7 @@ describe Ppl::Format::Table do
|
|
78
78
|
:name => "John Doe",
|
79
79
|
:email => "jdoe@example.org",
|
80
80
|
})
|
81
|
-
@table.to_s.
|
81
|
+
expect(@table.to_s).to eq "\e[31m12345 \e[0m\e[33mJohn Doe \e[0m\e[34mjdoe@example.org \e[0m"
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should align multiple rows into neat columns" do
|
@@ -93,8 +93,8 @@ describe Ppl::Format::Table do
|
|
93
93
|
:email => "lula@planalto.biz",
|
94
94
|
})
|
95
95
|
|
96
|
-
@table.to_s.
|
97
|
-
@table.to_s.
|
96
|
+
expect(@table.to_s).to include "12345 John Doe jdoe@example.org"
|
97
|
+
expect(@table.to_s).to include "123 Luis Ignacio Lula da Silva lula@planalto.biz"
|
98
98
|
end
|
99
99
|
|
100
100
|
it "copes with mixed encodings" do
|
@@ -104,7 +104,7 @@ describe Ppl::Format::Table do
|
|
104
104
|
:email => "fv@example.org",
|
105
105
|
})
|
106
106
|
expect{ @table.to_s }.not_to raise_error()
|
107
|
-
@table.to_s.
|
107
|
+
expect(@table.to_s).to include "franz_viehböck Franz Viehböck fv@example.org"
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
@@ -122,7 +122,7 @@ describe Ppl::Format::Table do
|
|
122
122
|
:email => "jdoe@example.org",
|
123
123
|
})
|
124
124
|
@table.disable_colors!
|
125
|
-
@table.to_s.
|
125
|
+
expect(@table.to_s).to eq "12345 John Doe jdoe@example.org"
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -4,7 +4,7 @@ describe Ppl::Service::EmailAddress do
|
|
4
4
|
@service = Ppl::Service::EmailAddress.new
|
5
5
|
@contact = Ppl::Entity::Contact.new
|
6
6
|
@storage = double(Ppl::Adapter::Storage)
|
7
|
-
@storage.
|
7
|
+
allow(@storage).to receive(:save_contact)
|
8
8
|
@service.storage = @storage
|
9
9
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("one@example.org")
|
10
10
|
end
|
@@ -12,19 +12,19 @@ describe Ppl::Service::EmailAddress do
|
|
12
12
|
describe "#add" do
|
13
13
|
|
14
14
|
it "should add the email address to the contact" do
|
15
|
-
@storage.
|
16
|
-
contact.email_addresses[1].address.
|
15
|
+
allow(@storage).to receive(:save_contact) do |contact|
|
16
|
+
expect(contact.email_addresses[1].address).to eq "two@example.org"
|
17
17
|
end
|
18
18
|
@service.add(@contact, "two@example.org", {})
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should set the new address as preferred if asked" do
|
22
22
|
@service.add(@contact, "two@example.org", {:preferred => true})
|
23
|
-
@contact.email_addresses[1].preferred.
|
23
|
+
expect(@contact.email_addresses[1].preferred).to eq true
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should store the contact" do
|
27
|
-
@storage.
|
27
|
+
expect(@storage).to receive(:save_contact).with(@contact)
|
28
28
|
@service.add(@contact, "", {})
|
29
29
|
end
|
30
30
|
|
@@ -32,21 +32,21 @@ describe Ppl::Service::EmailAddress do
|
|
32
32
|
|
33
33
|
describe "#update" do
|
34
34
|
it "should store the updated contact" do
|
35
|
-
@storage.
|
35
|
+
expect(@storage).to receive(:save_contact).with(@contact)
|
36
36
|
@service.update(@contact, "", {})
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should mark the address as preferred if asked to" do
|
40
|
-
@storage.
|
41
|
-
contact.email_addresses.first.preferred.
|
40
|
+
allow(@storage).to receive(:save_contact) do |contact|
|
41
|
+
expect(contact.email_addresses.first.preferred).to eq true
|
42
42
|
end
|
43
43
|
@service.update(@contact, "one@example.org", {:preferred => true})
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should mark the address as not preferred if asked to" do
|
47
47
|
@contact.email_addresses.first.preferred = true
|
48
|
-
@storage.
|
49
|
-
contact.email_addresses.first.preferred.
|
48
|
+
allow(@storage).to receive(:save_contact) do |contact|
|
49
|
+
expect(contact.email_addresses.first.preferred).to eq false
|
50
50
|
end
|
51
51
|
@service.update(@contact, "one@example.org", {:preferred => false})
|
52
52
|
end
|
@@ -55,14 +55,14 @@ describe Ppl::Service::EmailAddress do
|
|
55
55
|
describe "#remove" do
|
56
56
|
|
57
57
|
it "should remove the email address from the contact" do
|
58
|
-
@storage.
|
59
|
-
contact.email_addresses.length.
|
58
|
+
allow(@storage).to receive(:save_contact) do |contact|
|
59
|
+
expect(contact.email_addresses.length).to eq 0
|
60
60
|
end
|
61
61
|
@service.remove(@contact, "one@example.org")
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should store the contact" do
|
65
|
-
@storage.
|
65
|
+
expect(@storage).to receive(:save_contact).with(@contact)
|
66
66
|
@service.remove(@contact, "")
|
67
67
|
end
|
68
68
|
|
@@ -8,15 +8,15 @@ describe Ppl::Service::Name do
|
|
8
8
|
describe "#parse" do
|
9
9
|
|
10
10
|
it "uses the whole string for the full name" do
|
11
|
-
@service.parse("John Smith").full.
|
11
|
+
expect(@service.parse("John Smith").full).to eq "John Smith"
|
12
12
|
end
|
13
13
|
|
14
14
|
it "uses the first word for the given name" do
|
15
|
-
@service.parse("John Smith").given.
|
15
|
+
expect(@service.parse("John Smith").given).to eq "John"
|
16
16
|
end
|
17
17
|
|
18
18
|
it "uses the rest of the string for the family names" do
|
19
|
-
@service.parse("John Fitzgerald Donald Smith").family.
|
19
|
+
expect(@service.parse("John Fitzgerald Donald Smith").family).to eq "Fitzgerald Donald Smith"
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -25,32 +25,32 @@ describe Ppl::Service::Name do
|
|
25
25
|
|
26
26
|
it "updates the full name" do
|
27
27
|
@service.update(@name, {:full => "Abc Def"})
|
28
|
-
@name.full.
|
28
|
+
expect(@name.full).to eq "Abc Def"
|
29
29
|
end
|
30
30
|
|
31
31
|
it "updates the given names" do
|
32
32
|
@service.update(@name, {:given => "John"})
|
33
|
-
@name.given.
|
33
|
+
expect(@name.given).to eq "John"
|
34
34
|
end
|
35
35
|
|
36
36
|
it "updates the family names" do
|
37
37
|
@service.update(@name, {:family => "Smith"})
|
38
|
-
@name.family.
|
38
|
+
expect(@name.family).to eq "Smith"
|
39
39
|
end
|
40
40
|
|
41
41
|
it "updates the middle names" do
|
42
42
|
@service.update(@name, {:middle => "Arnold"})
|
43
|
-
@name.middle.
|
43
|
+
expect(@name.middle).to eq "Arnold"
|
44
44
|
end
|
45
45
|
|
46
46
|
it "updates the name prefix" do
|
47
47
|
@service.update(@name, {:prefix => "Mr"})
|
48
|
-
@name.prefix.
|
48
|
+
expect(@name.prefix).to eq "Mr"
|
49
49
|
end
|
50
50
|
|
51
51
|
it "updates the name suffix" do
|
52
52
|
@service.update(@name, {:suffix => "BSc"})
|
53
|
-
@name.suffix.
|
53
|
+
expect(@name.suffix).to eq "BSc"
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
@@ -4,7 +4,7 @@ describe Ppl::Service::PhoneNumber do
|
|
4
4
|
@service = Ppl::Service::PhoneNumber.new
|
5
5
|
@contact = Ppl::Entity::Contact.new
|
6
6
|
@storage = double(Ppl::Adapter::Storage)
|
7
|
-
@storage.
|
7
|
+
allow(@storage).to receive(:save_contact)
|
8
8
|
@service.storage = @storage
|
9
9
|
@contact.phone_numbers << Ppl::Entity::PhoneNumber.new("01234567890")
|
10
10
|
end
|
@@ -13,16 +13,16 @@ describe Ppl::Service::PhoneNumber do
|
|
13
13
|
|
14
14
|
it "should add the phone number to the contact" do
|
15
15
|
@service.add(@contact, "10987654321", {})
|
16
|
-
@contact.phone_numbers[1].number.
|
16
|
+
expect(@contact.phone_numbers[1].number).to eq "10987654321"
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should process the input options against the new contact" do
|
20
20
|
@service.add(@contact, "10987654321", {:preferred => true})
|
21
|
-
@contact.phone_numbers[1].preferred.
|
21
|
+
expect(@contact.phone_numbers[1].preferred).to eq true
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should store the contact" do
|
25
|
-
@storage.
|
25
|
+
expect(@storage).to receive(:save_contact).with(@contact)
|
26
26
|
@service.add(@contact, "", {})
|
27
27
|
end
|
28
28
|
|
@@ -32,25 +32,25 @@ describe Ppl::Service::PhoneNumber do
|
|
32
32
|
|
33
33
|
it "should update the number's type" do
|
34
34
|
@service.update(@contact, "01234567890", {:type => "cell"})
|
35
|
-
@contact.phone_numbers.first.type.
|
35
|
+
expect(@contact.phone_numbers.first.type).to eq "cell"
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should update the number's preferred status" do
|
39
39
|
@contact.phone_numbers << Ppl::Entity::PhoneNumber.new("109876543210")
|
40
40
|
@contact.phone_numbers[1].preferred = true
|
41
41
|
@service.update(@contact, "01234567890", {:preferred => true})
|
42
|
-
@contact.phone_numbers[0].preferred.
|
43
|
-
@contact.phone_numbers[1].preferred.
|
42
|
+
expect(@contact.phone_numbers[0].preferred).to eq true
|
43
|
+
expect(@contact.phone_numbers[1].preferred).to eq false
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should mark numbers as not preferred" do
|
47
47
|
@contact.phone_numbers[0].preferred = true
|
48
48
|
@service.update(@contact, "01234567890", {:preferred => false})
|
49
|
-
@contact.phone_numbers[0].preferred.
|
49
|
+
expect(@contact.phone_numbers[0].preferred).to eq false
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should store the contact" do
|
53
|
-
@storage.
|
53
|
+
expect(@storage).to receive(:save_contact).with(@contact)
|
54
54
|
@service.update(@contact, "", {})
|
55
55
|
end
|
56
56
|
|
@@ -60,11 +60,11 @@ describe Ppl::Service::PhoneNumber do
|
|
60
60
|
|
61
61
|
it "should remove the phone number from the contact" do
|
62
62
|
@service.remove(@contact, "01234567890")
|
63
|
-
@contact.phone_numbers.length.
|
63
|
+
expect(@contact.phone_numbers.length).to eq 0
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should store the contact" do
|
67
|
-
@storage.
|
67
|
+
expect(@storage).to receive(:save_contact).with(@contact)
|
68
68
|
@service.remove(@contact, "")
|
69
69
|
end
|
70
70
|
|