ppl 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +1 -0
  3. data/features/step_definitions/ppl_steps.rb +3 -3
  4. data/ppl.gemspec +1 -1
  5. data/spec/ppl/adapter/color/colored_spec.rb +3 -3
  6. data/spec/ppl/adapter/email_scraper/mail_spec.rb +13 -13
  7. data/spec/ppl/adapter/output_spec.rb +7 -7
  8. data/spec/ppl/adapter/storage/disk_spec.rb +18 -18
  9. data/spec/ppl/adapter/storage/factory_spec.rb +3 -3
  10. data/spec/ppl/adapter/storage/git_spec.rb +31 -31
  11. data/spec/ppl/adapter/storage_spec.rb +3 -3
  12. data/spec/ppl/adapter/vcard/greencard_spec.rb +45 -45
  13. data/spec/ppl/application/bootstrap_spec.rb +128 -128
  14. data/spec/ppl/application/command_spec.rb +8 -8
  15. data/spec/ppl/application/command_suite_spec.rb +7 -7
  16. data/spec/ppl/application/configuration_spec.rb +16 -16
  17. data/spec/ppl/application/input_spec.rb +2 -2
  18. data/spec/ppl/application/router_spec.rb +8 -8
  19. data/spec/ppl/application/shell_spec.rb +39 -39
  20. data/spec/ppl/command/add_spec.rb +6 -6
  21. data/spec/ppl/command/age_spec.rb +7 -7
  22. data/spec/ppl/command/attribute_spec.rb +22 -22
  23. data/spec/ppl/command/bday_spec.rb +11 -11
  24. data/spec/ppl/command/completion_spec.rb +7 -7
  25. data/spec/ppl/command/email_spec.rb +19 -19
  26. data/spec/ppl/command/external_spec.rb +7 -7
  27. data/spec/ppl/command/help_spec.rb +15 -15
  28. data/spec/ppl/command/init_spec.rb +5 -5
  29. data/spec/ppl/command/ls_spec.rb +12 -12
  30. data/spec/ppl/command/mutt_spec.rb +33 -33
  31. data/spec/ppl/command/mv_spec.rb +11 -11
  32. data/spec/ppl/command/name_spec.rb +17 -17
  33. data/spec/ppl/command/nick_spec.rb +1 -1
  34. data/spec/ppl/command/org_spec.rb +1 -1
  35. data/spec/ppl/command/phone_spec.rb +15 -15
  36. data/spec/ppl/command/post_spec.rb +29 -29
  37. data/spec/ppl/command/rm_spec.rb +3 -3
  38. data/spec/ppl/command/scrape_spec.rb +24 -24
  39. data/spec/ppl/command/shell_spec.rb +41 -41
  40. data/spec/ppl/command/show_spec.rb +4 -4
  41. data/spec/ppl/command/url_spec.rb +1 -1
  42. data/spec/ppl/command/version_spec.rb +4 -4
  43. data/spec/ppl/entity/address_book_spec.rb +1 -1
  44. data/spec/ppl/entity/contact_spec.rb +16 -16
  45. data/spec/ppl/entity/email_address_spec.rb +3 -3
  46. data/spec/ppl/entity/name_spec.rb +1 -1
  47. data/spec/ppl/entity/phone_number_spec.rb +5 -5
  48. data/spec/ppl/entity/postal_address_spec.rb +2 -2
  49. data/spec/ppl/format/address_book/ages_spec.rb +3 -3
  50. data/spec/ppl/format/address_book/birthdays_spec.rb +3 -3
  51. data/spec/ppl/format/address_book/email_addresses_spec.rb +3 -3
  52. data/spec/ppl/format/address_book/mutt_query_spec.rb +3 -3
  53. data/spec/ppl/format/address_book/names_spec.rb +3 -3
  54. data/spec/ppl/format/address_book/nicknames_spec.rb +4 -4
  55. data/spec/ppl/format/address_book/one_line_spec.rb +5 -5
  56. data/spec/ppl/format/address_book/organizations_spec.rb +3 -3
  57. data/spec/ppl/format/address_book/phone_numbers_spec.rb +3 -3
  58. data/spec/ppl/format/address_book/postal_addresses_spec.rb +2 -2
  59. data/spec/ppl/format/address_book/urls_spec.rb +3 -3
  60. data/spec/ppl/format/contact/age_spec.rb +8 -8
  61. data/spec/ppl/format/contact/birthday_spec.rb +4 -4
  62. data/spec/ppl/format/contact/email_addresses_spec.rb +3 -3
  63. data/spec/ppl/format/contact/full_spec.rb +11 -11
  64. data/spec/ppl/format/contact/nicknames_spec.rb +4 -4
  65. data/spec/ppl/format/contact/organization_spec.rb +4 -4
  66. data/spec/ppl/format/contact/phone_number_spec.rb +4 -4
  67. data/spec/ppl/format/contact/postal_address_spec.rb +1 -1
  68. data/spec/ppl/format/contact/postal_addresses_spec.rb +3 -3
  69. data/spec/ppl/format/contact/urls_spec.rb +4 -4
  70. data/spec/ppl/format/custom/contact_spec.rb +13 -13
  71. data/spec/ppl/format/custom/email_address_spec.rb +3 -3
  72. data/spec/ppl/format/custom/phone_number_spec.rb +4 -4
  73. data/spec/ppl/format/custom_spec.rb +6 -6
  74. data/spec/ppl/format/name/full_only_spec.rb +4 -4
  75. data/spec/ppl/format/postal_address/multi_line_spec.rb +10 -10
  76. data/spec/ppl/format/postal_address/one_line_spec.rb +9 -9
  77. data/spec/ppl/format/table_spec.rb +11 -11
  78. data/spec/ppl/service/email_address_spec.rb +13 -13
  79. data/spec/ppl/service/name_spec.rb +9 -9
  80. data/spec/ppl/service/phone_number_spec.rb +11 -11
  81. data/spec/ppl/service/postal_address_spec.rb +20 -20
  82. data/spec/spec_helper.rb +3 -0
  83. 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.should_receive(:load_address_book).and_return(@address_book)
25
- @list_format.should_receive(:process).and_return("imagine this is a list")
26
- @output.should_receive(:line).with("imagine this is a list")
27
- @command.execute(@input, @output).should eq true
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.stub(:load_address_book).and_return(@address_book)
33
- @list_format.should_receive(:disable_colors!)
34
- @list_format.stub(:process)
35
- @output.should_receive(:line)
36
- @command.execute(@input, @output).should eq true
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.should_receive(:require_contact).and_return(@contact)
42
- @show_format.should_receive(:process).and_return("all the info")
43
- @output.should_receive(:line).with("all the info")
44
- @command.execute(@input, @output).should eq true
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.should_receive(:require_contact).and_return(@contact)
50
- @contact.should_receive(:phone_numbers).and_return([])
51
- @storage.should_receive(:save_contact)
52
- @command.execute(@input, @output).should eq true
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.should_receive(:delete)
57
+ expect(phone_numbers).to receive(:delete)
58
58
 
59
- @storage.should_receive(:require_contact).and_return(@contact)
60
- @contact.should_receive(:phone_numbers).and_return(phone_numbers)
61
- @storage.should_receive(:save_contact).and_return(true)
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).should eq true
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.should eq "bday"
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.should_receive(:require_contact).and_return(@contact)
26
- @show_format.should_receive(:process).and_return("1970-01-01")
27
- @output.should_receive(:line).with("1970-01-01")
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).should eq true
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.should_receive(:require_contact).and_return(@contact)
34
- @show_format.should_receive(:process).and_return("")
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).should eq false
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.should_receive(:require_contact).and_return(@contact)
41
- @storage.should_receive(:save_contact) do |contact|
42
- contact.birthday.strftime.should eq "1980-01-01"
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.should eq "completion"
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.stub(:path).and_return("")
21
- File.stub(:exists?).and_return(true)
22
- File.stub(:read)
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.should_receive(:exists?).with("/invalidshell").and_return(false)
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.should_receive(:read).and_return("completion function")
39
- @output.should_receive(:line).with("completion function")
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.should eq "email"
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.stub(:require_contact).and_return(@contact)
25
- @storage.stub(:save_contact)
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.should_receive(:load_address_book).and_return(@address_book)
35
- @list_format.should_receive(:process).and_return("imagine this is a list")
36
- @output.should_receive(:line).with("imagine this is a list")
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.should_receive(:require_contact).and_return(@contact)
43
- @show_format.should_receive(:process).and_return("imagine this is a list")
44
- @output.should_receive(:line).with("imagine this is a list")
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.should_receive(:require_contact).and_return(@contact)
53
- @custom_format.should_receive(:format=).with("%e")
54
- @custom_format.should_receive(:process).and_return("")
55
- @output.should_receive(:line).with("")
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.should_receive(:require_contact).and_return(@contact)
62
- @service.should_receive(:add).with(@contact, "jdoe@example.org", @input.options)
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.should_receive(:require_contact).and_return(@contact)
70
- @service.should_receive(:update).with(@contact, "jdoe@example.org", {})
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.should_receive(:require_contact).and_return(@contact)
78
- @service.should_receive(:remove).with(@contact, "jdoe@example.org")
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.stub(:path).and_return("/contacts")
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.should_receive(:chdir).with("/contacts")
17
- Kernel.stub(:exec)
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.stub(:chdir)
23
- Kernel.should_receive(:exec).with("git remote")
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.stub(:chdir)
30
- Kernel.should_receive(:exec).with("git remote --help")
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.should be 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.should eq "help"
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.should_receive(:line).with("usage: ppl <command>")
30
- @output.should_receive(:line).with(nil)
31
- @output.should_receive(:line).with(nil)
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.should_receive(:name).twice.and_return("one")
39
- command.should_receive(:description).and_return("The first 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.should_receive(:line).with("usage: ppl <command>")
43
- @output.should_receive(:line).with(nil)
44
- @output.should_receive(:line).with(" one The first command")
45
- @output.should_receive(:line).with(nil)
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.should_receive(:line).with("usage: ppl <command>")
63
- @output.should_receive(:line).with(nil)
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.should_receive(:line).with(line)
68
+ expect(@output).to receive(:line).with(line)
69
69
  end
70
- @output.should_receive(:line).with(nil)
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.should eq "init"
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.stub(:create_address_book) do |path|
19
- path.should eq "/contacts"
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.stub(:create_address_book) do |path|
30
- path.should eq "/current"
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!
@@ -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.should eq "ls"
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.should_receive(:load_address_book).and_return(@address_book)
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.should_receive(:process).and_return("list of contacts")
35
- @output.should_receive(:line).with("list of contacts")
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.should_receive(:contacts).and_return([1])
41
- @custom.should_receive(:use_preset).with("test")
42
- @custom.should_receive(:process).and_return("list of contacts")
43
- @output.should_receive(:line).with("list of contacts")
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.should_receive(:contacts).and_return([1])
49
- @custom.should_receive(:format=).with("%n")
50
- @custom.should_receive(:process).and_return("list of contacts")
51
- @output.should_receive(:line).with("list of contacts")
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.should eq "mutt"
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.should_receive(:mutt_search).and_return(Ppl::Entity::AddressBook.new)
33
- @output.should_receive(:line).with("No matches")
34
- @command.execute(@input, @output).should eq false
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.should_receive(:load_address_book).and_return(@address_book)
46
- @format.should_receive(:process).and_return("test@example.org\tTest User")
47
- @output.should_receive(:line) do |line|
48
- line.should include "Searching address book... 1 email addresses... 1 matching:"
49
- line.should include "test@example.org\tTest User"
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).should eq true
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.stub(:load_address_book).and_return(@address_book)
62
- @format.should_receive(:process) do |address_book|
63
- address_book.contacts[0].email_addresses.length.should eq 1
64
- address_book.contacts[0].email_addresses[0].address.should eq "prova@prova.org"
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.stub(:line)
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.should_receive(:load_address_book).and_return(@address_book)
79
- @format.should_receive(:process).and_return("test@example.org\tTest User")
80
- @output.should_receive(:line) do |line|
81
- line.should include "Searching address book... 1 email addresses... 1 matching:"
82
- line.should include "test@example.org\tTest User"
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).should eq true
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.stub(:load_address_book).and_return(@address_book)
97
- @format.stub(:process)
98
- @output.stub(:line)
99
- @output.should_receive(:line) do |line|
100
- line.should include "Searching address book... 2 email addresses... 2 matching:"
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.stub(:load_address_book).and_return(@address_book)
116
- @output.stub(:line)
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.should_receive(:process) do |address_book|
122
- address_book.contacts[0].email_addresses.length.should eq 2
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.should_receive(:process) do |address_book|
130
- address_book.contacts[0].email_addresses.length.should eq 1
131
- address_book.contacts[0].email_addresses[0].address.should eq "LOUD@SHOUTING.COM"
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