ppl 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -21,47 +21,47 @@ describe Ppl::Command::Attribute do
|
|
21
21
|
describe "#execute" do
|
22
22
|
|
23
23
|
it "should list all the contacts and the value of the attribute for each" do
|
24
|
-
@storage.
|
25
|
-
@list_format.
|
26
|
-
@output.
|
27
|
-
@command.execute(@input, @output).
|
24
|
+
expect(@storage).to receive(:load_address_book).and_return(@address_book)
|
25
|
+
expect(@list_format).to receive(:process).and_return("imagine this is a list")
|
26
|
+
expect(@output).to receive(:line).with("imagine this is a list")
|
27
|
+
expect(@command.execute(@input, @output)).to eq true
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should disable color output if :no_color is set" do
|
31
31
|
@input.options[:no_color] = true
|
32
|
-
@storage.
|
33
|
-
@list_format.
|
34
|
-
@list_format.
|
35
|
-
@output.
|
36
|
-
@command.execute(@input, @output).
|
32
|
+
allow(@storage).to receive(:load_address_book).and_return(@address_book)
|
33
|
+
expect(@list_format).to receive(:disable_colors!)
|
34
|
+
allow(@list_format).to receive(:process)
|
35
|
+
expect(@output).to receive(:line)
|
36
|
+
expect(@command.execute(@input, @output)).to eq true
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should show the full list of attributes for the given contact" do
|
40
40
|
@input.arguments.push("jdoe")
|
41
|
-
@storage.
|
42
|
-
@show_format.
|
43
|
-
@output.
|
44
|
-
@command.execute(@input, @output).
|
41
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
42
|
+
expect(@show_format).to receive(:process).and_return("all the info")
|
43
|
+
expect(@output).to receive(:line).with("all the info")
|
44
|
+
expect(@command.execute(@input, @output)).to eq true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should add the given value to the contact's attributes" do
|
48
48
|
@input.arguments.push("jdoe", "anyvalue")
|
49
|
-
@storage.
|
50
|
-
@contact.
|
51
|
-
@storage.
|
52
|
-
@command.execute(@input, @output).
|
49
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
50
|
+
expect(@contact).to receive(:phone_numbers).and_return([])
|
51
|
+
expect(@storage).to receive(:save_contact)
|
52
|
+
expect(@command.execute(@input, @output)).to eq true
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should delete the given value from the contact's attributes" do
|
56
56
|
phone_numbers = double(Array)
|
57
|
-
phone_numbers.
|
57
|
+
expect(phone_numbers).to receive(:delete)
|
58
58
|
|
59
|
-
@storage.
|
60
|
-
@contact.
|
61
|
-
@storage.
|
59
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
60
|
+
expect(@contact).to receive(:phone_numbers).and_return(phone_numbers)
|
61
|
+
expect(@storage).to receive(:save_contact).and_return(true)
|
62
62
|
@input.arguments = ["jdoe", "somevalue"]
|
63
63
|
@input.options = { :delete => true }
|
64
|
-
@command.execute(@input, @output).
|
64
|
+
expect(@command.execute(@input, @output)).to eq true
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
@@ -15,31 +15,31 @@ describe Ppl::Command::Bday do
|
|
15
15
|
|
16
16
|
describe "#name" do
|
17
17
|
it "should be 'bday'" do
|
18
|
-
@command.name.
|
18
|
+
expect(@command.name).to eq "bday"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "#execute" do
|
23
23
|
|
24
24
|
it "should show the contact's birthday if no date is given" do
|
25
|
-
@storage.
|
26
|
-
@show_format.
|
27
|
-
@output.
|
25
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
26
|
+
expect(@show_format).to receive(:process).and_return("1970-01-01")
|
27
|
+
expect(@output).to receive(:line).with("1970-01-01")
|
28
28
|
@input.arguments = ["jim"]
|
29
|
-
@command.execute(@input, @output).
|
29
|
+
expect(@command.execute(@input, @output)).to eq true
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should not output anything if there's no birthday to show" do
|
33
|
-
@storage.
|
34
|
-
@show_format.
|
33
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
34
|
+
expect(@show_format).to receive(:process).and_return("")
|
35
35
|
@input.arguments = ["jim"]
|
36
|
-
@command.execute(@input, @output).
|
36
|
+
expect(@command.execute(@input, @output)).to eq false
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should change the contact's birthday if a date is given" do
|
40
|
-
@storage.
|
41
|
-
@storage.
|
42
|
-
contact.birthday.strftime.
|
40
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
41
|
+
expect(@storage).to receive(:save_contact) do |contact|
|
42
|
+
expect(contact.birthday.strftime).to eq "1980-01-01"
|
43
43
|
end
|
44
44
|
@input.arguments = ["jim", "1980-01-01"]
|
45
45
|
@command.execute(@input, @output)
|
@@ -10,16 +10,16 @@ describe Ppl::Command::Completion do
|
|
10
10
|
|
11
11
|
describe "#name" do
|
12
12
|
it "should be 'completion'" do
|
13
|
-
@command.name.
|
13
|
+
expect(@command.name).to eq "completion"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "#execute" do
|
18
18
|
|
19
19
|
before(:each) do
|
20
|
-
@directory.
|
21
|
-
File.
|
22
|
-
File.
|
20
|
+
allow(@directory).to receive(:path).and_return("")
|
21
|
+
allow(File).to receive(:exists?).and_return(true)
|
22
|
+
allow(File).to receive(:read)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should raise an error if no shell is specified" do
|
@@ -29,14 +29,14 @@ describe Ppl::Command::Completion do
|
|
29
29
|
|
30
30
|
it "should raise an error if the shell is not recognised" do
|
31
31
|
@input.arguments = ["invalidshell"]
|
32
|
-
File.
|
32
|
+
expect(File).to receive(:exists?).with("/invalidshell").and_return(false)
|
33
33
|
expect{@command.execute(@input, @output)}.to raise_error(Ppl::Error::CompletionNotFound)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should read the function from disk and print it to stdout" do
|
37
37
|
@input.arguments = ["zsh"]
|
38
|
-
File.
|
39
|
-
@output.
|
38
|
+
expect(File).to receive(:read).and_return("completion function")
|
39
|
+
expect(@output).to receive(:line).with("completion function")
|
40
40
|
@command.execute(@input, @output)
|
41
41
|
end
|
42
42
|
|
@@ -6,7 +6,7 @@ describe Ppl::Command::Email do
|
|
6
6
|
|
7
7
|
describe "#name" do
|
8
8
|
it "should be 'email'" do
|
9
|
-
@command.name.
|
9
|
+
expect(@command.name).to eq "email"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -21,8 +21,8 @@ describe Ppl::Command::Email do
|
|
21
21
|
@list_format = double(Ppl::Format::AddressBook)
|
22
22
|
@show_format = double(Ppl::Format::Contact)
|
23
23
|
@custom_format = double(Ppl::Format::Custom)
|
24
|
-
@storage.
|
25
|
-
@storage.
|
24
|
+
allow(@storage).to receive(:require_contact).and_return(@contact)
|
25
|
+
allow(@storage).to receive(:save_contact)
|
26
26
|
@command.storage = @storage
|
27
27
|
@command.email_service = @service
|
28
28
|
@command.list_format = @list_format
|
@@ -31,17 +31,17 @@ describe Ppl::Command::Email do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should list all email addresses by default" do
|
34
|
-
@storage.
|
35
|
-
@list_format.
|
36
|
-
@output.
|
34
|
+
expect(@storage).to receive(:load_address_book).and_return(@address_book)
|
35
|
+
expect(@list_format).to receive(:process).and_return("imagine this is a list")
|
36
|
+
expect(@output).to receive(:line).with("imagine this is a list")
|
37
37
|
@command.execute(@input, @output)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should show a single contact's addresses if one is specified" do
|
41
41
|
@input.arguments << "jdoe"
|
42
|
-
@storage.
|
43
|
-
@show_format.
|
44
|
-
@output.
|
42
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
43
|
+
expect(@show_format).to receive(:process).and_return("imagine this is a list")
|
44
|
+
expect(@output).to receive(:line).with("imagine this is a list")
|
45
45
|
@command.execute(@input, @output)
|
46
46
|
end
|
47
47
|
|
@@ -49,33 +49,33 @@ describe Ppl::Command::Email do
|
|
49
49
|
@input.arguments << "jdoe"
|
50
50
|
@input.options[:format] = "%e"
|
51
51
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("jdoe@example.org")
|
52
|
-
@storage.
|
53
|
-
@custom_format.
|
54
|
-
@custom_format.
|
55
|
-
@output.
|
52
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
53
|
+
expect(@custom_format).to receive(:format=).with("%e")
|
54
|
+
expect(@custom_format).to receive(:process).and_return("")
|
55
|
+
expect(@output).to receive(:line).with("")
|
56
56
|
@command.execute(@input, @output)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should delegate to the service layer to add a new email address" do
|
60
60
|
@input.arguments = ["jdoe", "jdoe@example.org"]
|
61
|
-
@storage.
|
62
|
-
@service.
|
61
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
62
|
+
expect(@service).to receive(:add).with(@contact, "jdoe@example.org", @input.options)
|
63
63
|
@command.execute(@input, @output)
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should delegate to the service layer to update an existing address" do
|
67
67
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("jdoe@example.org")
|
68
68
|
@input.arguments = ["jdoe", "jdoe@example.org"]
|
69
|
-
@storage.
|
70
|
-
@service.
|
69
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
70
|
+
expect(@service).to receive(:update).with(@contact, "jdoe@example.org", {})
|
71
71
|
@command.execute(@input, @output)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should delegate to the service layer to remove an email address" do
|
75
75
|
@input.arguments = ["jdoe", "jdoe@example.org"]
|
76
76
|
@input.options[:delete] = true
|
77
|
-
@storage.
|
78
|
-
@service.
|
77
|
+
expect(@storage).to receive(:require_contact).and_return(@contact)
|
78
|
+
expect(@service).to receive(:remove).with(@contact, "jdoe@example.org")
|
79
79
|
@command.execute(@input, @output)
|
80
80
|
end
|
81
81
|
|
@@ -6,28 +6,28 @@ describe Ppl::Command::External do
|
|
6
6
|
@output = double(Ppl::Application::Output)
|
7
7
|
@storage = double(Ppl::Adapter::Storage)
|
8
8
|
|
9
|
-
@storage.
|
9
|
+
allow(@storage).to receive(:path).and_return("/contacts")
|
10
10
|
@command.storage = @storage
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#execute" do
|
14
14
|
|
15
15
|
it "should chdir to the location of the address book on disk" do
|
16
|
-
Dir.
|
17
|
-
Kernel.
|
16
|
+
expect(Dir).to receive(:chdir).with("/contacts")
|
17
|
+
allow(Kernel).to receive(:exec)
|
18
18
|
@command.execute(@input, @output)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should run the specified command" do
|
22
|
-
Dir.
|
23
|
-
Kernel.
|
22
|
+
allow(Dir).to receive(:chdir)
|
23
|
+
expect(Kernel).to receive(:exec).with("git remote")
|
24
24
|
@command.execute(@input, @output)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should pass arguments through to the command" do
|
28
28
|
@input.arguments = ["--help"]
|
29
|
-
Dir.
|
30
|
-
Kernel.
|
29
|
+
allow(Dir).to receive(:chdir)
|
30
|
+
expect(Kernel).to receive(:exec).with("git remote --help")
|
31
31
|
@command.execute(@input, @output)
|
32
32
|
end
|
33
33
|
|
@@ -11,13 +11,13 @@ describe Ppl::Command::Help do
|
|
11
11
|
it "should accept a value" do
|
12
12
|
suite = Object.new
|
13
13
|
@command.command_suite = suite
|
14
|
-
@command.command_suite.
|
14
|
+
expect(@command.command_suite).to be suite
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#name" do
|
19
19
|
it "should be 'help'" do
|
20
|
-
@command.name.
|
20
|
+
expect(@command.name).to eq "help"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -26,23 +26,23 @@ describe Ppl::Command::Help do
|
|
26
26
|
it "should not list itself" do
|
27
27
|
@command.command_suite.add_command(@command)
|
28
28
|
|
29
|
-
@output.
|
30
|
-
@output.
|
31
|
-
@output.
|
29
|
+
expect(@output).to receive(:line).with("usage: ppl <command>")
|
30
|
+
expect(@output).to receive(:line).with(nil)
|
31
|
+
expect(@output).to receive(:line).with(nil)
|
32
32
|
|
33
33
|
@command.execute(nil, @output)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should list available commands" do
|
37
37
|
command = double(Ppl::Application::Command)
|
38
|
-
command.
|
39
|
-
command.
|
38
|
+
expect(command).to receive(:name).twice.and_return("one")
|
39
|
+
expect(command).to receive(:description).and_return("The first command")
|
40
40
|
@command.command_suite.add_command(command)
|
41
41
|
|
42
|
-
@output.
|
43
|
-
@output.
|
44
|
-
@output.
|
45
|
-
@output.
|
42
|
+
expect(@output).to receive(:line).with("usage: ppl <command>")
|
43
|
+
expect(@output).to receive(:line).with(nil)
|
44
|
+
expect(@output).to receive(:line).with(" one The first command")
|
45
|
+
expect(@output).to receive(:line).with(nil)
|
46
46
|
|
47
47
|
@command.execute(nil, @output)
|
48
48
|
end
|
@@ -59,15 +59,15 @@ describe Ppl::Command::Help do
|
|
59
59
|
@command.command_suite.add_command(command_foo)
|
60
60
|
@command.command_suite.add_command(command_bar)
|
61
61
|
|
62
|
-
@output.
|
63
|
-
@output.
|
62
|
+
expect(@output).to receive(:line).with("usage: ppl <command>")
|
63
|
+
expect(@output).to receive(:line).with(nil)
|
64
64
|
[
|
65
65
|
" shortname This is a command with a short name",
|
66
66
|
" veryverylongname This is a command with a longer name",
|
67
67
|
].each do |line|
|
68
|
-
@output.
|
68
|
+
expect(@output).to receive(:line).with(line)
|
69
69
|
end
|
70
|
-
@output.
|
70
|
+
expect(@output).to receive(:line).with(nil)
|
71
71
|
|
72
72
|
@command.execute(nil, @output)
|
73
73
|
end
|
@@ -8,15 +8,15 @@ describe Ppl::Command::Init do
|
|
8
8
|
|
9
9
|
describe "#name" do
|
10
10
|
it "should be 'init'" do
|
11
|
-
@command.name.
|
11
|
+
expect(@command.name).to eq "init"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#execute" do
|
16
16
|
|
17
17
|
it "should pass the given path through to the storage adapter" do
|
18
|
-
Ppl::Adapter::Storage::Git.
|
19
|
-
path.
|
18
|
+
allow(Ppl::Adapter::Storage::Git).to receive(:create_address_book) do |path|
|
19
|
+
expect(path).to eq "/contacts"
|
20
20
|
end
|
21
21
|
@input.arguments.push "/contacts"
|
22
22
|
@command.execute(@input, @output)
|
@@ -26,8 +26,8 @@ describe Ppl::Command::Init do
|
|
26
26
|
FakeFS.activate!
|
27
27
|
Dir.mkdir "/current"
|
28
28
|
Dir.chdir "/current"
|
29
|
-
Ppl::Adapter::Storage::Git.
|
30
|
-
path.
|
29
|
+
allow(Ppl::Adapter::Storage::Git).to receive(:create_address_book) do |path|
|
30
|
+
expect(path).to eq "/current"
|
31
31
|
end
|
32
32
|
@command.execute(@input, @output)
|
33
33
|
FakeFS.deactivate!
|
data/spec/ppl/command/ls_spec.rb
CHANGED
@@ -16,14 +16,14 @@ describe Ppl::Command::Ls do
|
|
16
16
|
|
17
17
|
describe "#name" do
|
18
18
|
it "should be 'ls'" do
|
19
|
-
@command.name.
|
19
|
+
expect(@command.name).to eq "ls"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "#execute" do
|
24
24
|
|
25
25
|
before(:each) do
|
26
|
-
@storage.
|
26
|
+
expect(@storage).to receive(:load_address_book).and_return(@address_book)
|
27
27
|
end
|
28
28
|
|
29
29
|
after(:each) do
|
@@ -31,24 +31,24 @@ describe Ppl::Command::Ls do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should show the list of contacts in the address book" do
|
34
|
-
@format.
|
35
|
-
@output.
|
34
|
+
expect(@format).to receive(:process).and_return("list of contacts")
|
35
|
+
expect(@output).to receive(:line).with("list of contacts")
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should let the user specify a preset pretty format" do
|
39
39
|
@input.options[:pretty] = "test"
|
40
|
-
@address_book.
|
41
|
-
@custom.
|
42
|
-
@custom.
|
43
|
-
@output.
|
40
|
+
expect(@address_book).to receive(:contacts).and_return([1])
|
41
|
+
expect(@custom).to receive(:use_preset).with("test")
|
42
|
+
expect(@custom).to receive(:process).and_return("list of contacts")
|
43
|
+
expect(@output).to receive(:line).with("list of contacts")
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should let the user specify a custom format" do
|
47
47
|
@input.options[:format] = "%n"
|
48
|
-
@address_book.
|
49
|
-
@custom.
|
50
|
-
@custom.
|
51
|
-
@output.
|
48
|
+
expect(@address_book).to receive(:contacts).and_return([1])
|
49
|
+
expect(@custom).to receive(:format=).with("%n")
|
50
|
+
expect(@custom).to receive(:process).and_return("list of contacts")
|
51
|
+
expect(@output).to receive(:line).with("list of contacts")
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
@@ -17,7 +17,7 @@ describe Ppl::Command::Mutt do
|
|
17
17
|
|
18
18
|
describe "#name" do
|
19
19
|
it "should be 'mutt'" do
|
20
|
-
@command.name.
|
20
|
+
expect(@command.name).to eq "mutt"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -29,9 +29,9 @@ describe Ppl::Command::Mutt do
|
|
29
29
|
|
30
30
|
it "should search the address book for the query" do
|
31
31
|
@input.arguments.push "query"
|
32
|
-
@command.
|
33
|
-
@output.
|
34
|
-
@command.execute(@input, @output).
|
32
|
+
expect(@command).to receive(:mutt_search).and_return(Ppl::Entity::AddressBook.new)
|
33
|
+
expect(@output).to receive(:line).with("No matches")
|
34
|
+
expect(@command.execute(@input, @output)).to eq false
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should return email address matches" do
|
@@ -42,13 +42,13 @@ describe Ppl::Command::Mutt do
|
|
42
42
|
|
43
43
|
@input.arguments.push "example"
|
44
44
|
|
45
|
-
@storage.
|
46
|
-
@format.
|
47
|
-
@output.
|
48
|
-
line.
|
49
|
-
line.
|
45
|
+
expect(@storage).to receive(:load_address_book).and_return(@address_book)
|
46
|
+
expect(@format).to receive(:process).and_return("test@example.org\tTest User")
|
47
|
+
expect(@output).to receive(:line) do |line|
|
48
|
+
expect(line).to include "Searching address book... 1 email addresses... 1 matching:"
|
49
|
+
expect(line).to include "test@example.org\tTest User"
|
50
50
|
end
|
51
|
-
@command.execute(@input, @output).
|
51
|
+
expect(@command.execute(@input, @output)).to eq true
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should only return matching email addresses" do
|
@@ -58,12 +58,12 @@ describe Ppl::Command::Mutt do
|
|
58
58
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("test@test.org")
|
59
59
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("prova@prova.org")
|
60
60
|
@address_book.contacts.push(@contact)
|
61
|
-
@storage.
|
62
|
-
@format.
|
63
|
-
address_book.contacts[0].email_addresses.length.
|
64
|
-
address_book.contacts[0].email_addresses[0].address.
|
61
|
+
allow(@storage).to receive(:load_address_book).and_return(@address_book)
|
62
|
+
expect(@format).to receive(:process) do |address_book|
|
63
|
+
expect(address_book.contacts[0].email_addresses.length).to eq 1
|
64
|
+
expect(address_book.contacts[0].email_addresses[0].address).to eq "prova@prova.org"
|
65
65
|
end
|
66
|
-
@output.
|
66
|
+
allow(@output).to receive(:line)
|
67
67
|
@command.execute(@input, @output)
|
68
68
|
end
|
69
69
|
|
@@ -75,13 +75,13 @@ describe Ppl::Command::Mutt do
|
|
75
75
|
|
76
76
|
@input.arguments.push "User"
|
77
77
|
|
78
|
-
@storage.
|
79
|
-
@format.
|
80
|
-
@output.
|
81
|
-
line.
|
82
|
-
line.
|
78
|
+
expect(@storage).to receive(:load_address_book).and_return(@address_book)
|
79
|
+
expect(@format).to receive(:process).and_return("test@example.org\tTest User")
|
80
|
+
expect(@output).to receive(:line) do |line|
|
81
|
+
expect(line).to include "Searching address book... 1 email addresses... 1 matching:"
|
82
|
+
expect(line).to include "test@example.org\tTest User"
|
83
83
|
end
|
84
|
-
@command.execute(@input, @output).
|
84
|
+
expect(@command.execute(@input, @output)).to eq true
|
85
85
|
end
|
86
86
|
|
87
87
|
|
@@ -93,11 +93,11 @@ describe Ppl::Command::Mutt do
|
|
93
93
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("prova@prova.org")
|
94
94
|
@address_book.contacts << @contact
|
95
95
|
|
96
|
-
@storage.
|
97
|
-
@format.
|
98
|
-
@output.
|
99
|
-
@output.
|
100
|
-
line.
|
96
|
+
allow(@storage).to receive(:load_address_book).and_return(@address_book)
|
97
|
+
allow(@format).to receive(:process)
|
98
|
+
allow(@output).to receive(:line)
|
99
|
+
expect(@output).to receive(:line) do |line|
|
100
|
+
expect(line).to include "Searching address book... 2 email addresses... 2 matching:"
|
101
101
|
end
|
102
102
|
@command.execute(@input, @output)
|
103
103
|
end
|
@@ -112,23 +112,23 @@ describe Ppl::Command::Mutt do
|
|
112
112
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("joe@somewhere.com")
|
113
113
|
@contact.email_addresses << Ppl::Entity::EmailAddress.new("LOUD@SHOUTING.COM")
|
114
114
|
@address_book.contacts << @contact
|
115
|
-
@storage.
|
116
|
-
@output.
|
115
|
+
allow(@storage).to receive(:load_address_book).and_return(@address_book)
|
116
|
+
allow(@output).to receive(:line)
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should ignore case when matching names" do
|
120
120
|
@input.arguments.push "joe schmoe"
|
121
|
-
@format.
|
122
|
-
address_book.contacts[0].email_addresses.length.
|
121
|
+
expect(@format).to receive(:process) do |address_book|
|
122
|
+
expect(address_book.contacts[0].email_addresses.length).to eq 2
|
123
123
|
end
|
124
124
|
@command.execute(@input, @output)
|
125
125
|
end
|
126
126
|
|
127
127
|
it "should ignore case when matching email addresses" do
|
128
128
|
@input.arguments.push "loud"
|
129
|
-
@format.
|
130
|
-
address_book.contacts[0].email_addresses.length.
|
131
|
-
address_book.contacts[0].email_addresses[0].address.
|
129
|
+
expect(@format).to receive(:process) do |address_book|
|
130
|
+
expect(address_book.contacts[0].email_addresses.length).to eq 1
|
131
|
+
expect(address_book.contacts[0].email_addresses[0].address).to eq "LOUD@SHOUTING.COM"
|
132
132
|
end
|
133
133
|
@command.execute(@input, @output)
|
134
134
|
end
|