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
@@ -13,7 +13,7 @@ describe Ppl::Command::Mv do
13
13
 
14
14
  describe "#name" do
15
15
  it "should be 'mv'" do
16
- @command.name.should eq "mv"
16
+ expect(@command.name).to eq "mv"
17
17
  end
18
18
  end
19
19
 
@@ -30,24 +30,24 @@ describe Ppl::Command::Mv do
30
30
  end
31
31
 
32
32
  it "should return false if the new id is taken" do
33
- @storage.should_receive(:require_contact).with("old").and_return(@contact)
34
- @storage.should_receive(:load_contact).with("new").and_return(@contact)
35
- @output.should_receive(:error)
33
+ expect(@storage).to receive(:require_contact).with("old").and_return(@contact)
34
+ expect(@storage).to receive(:load_contact).with("new").and_return(@contact)
35
+ expect(@output).to receive(:error)
36
36
  @input.arguments = ["old", "new"]
37
37
 
38
- @command.execute(@input, @output).should eq false
38
+ expect(@command.execute(@input, @output)).to eq false
39
39
  end
40
40
 
41
41
  it "should rename the given contact" do
42
- @storage.should_receive(:require_contact).with("old").and_return(@contact)
43
- @storage.should_receive(:load_contact).with("new").and_return(nil)
42
+ expect(@storage).to receive(:require_contact).with("old").and_return(@contact)
43
+ expect(@storage).to receive(:load_contact).with("new").and_return(nil)
44
44
 
45
- @storage.should_receive(:delete_contact).with(@contact) do |contact|
46
- contact.id.should eq "old"
45
+ expect(@storage).to receive(:delete_contact).with(@contact) do |contact|
46
+ expect(contact.id).to eq "old"
47
47
  end
48
48
 
49
- @storage.should_receive(:save_contact).with(@contact) do |contact|
50
- contact.id.should eq "new"
49
+ expect(@storage).to receive(:save_contact).with(@contact) do |contact|
50
+ expect(contact.id).to eq "new"
51
51
  end
52
52
 
53
53
  @input.arguments = ["old", "new"]
@@ -24,51 +24,51 @@ describe Ppl::Command::Name do
24
24
 
25
25
  describe "#name" do
26
26
  it "should be 'name'" do
27
- @command.name.should eq "name"
27
+ expect(@command.name).to eq "name"
28
28
  end
29
29
  end
30
30
 
31
31
  describe "#execute" do
32
32
 
33
33
  it "should list all contact names if no contact ID is given" do
34
- @storage.should_receive(:load_address_book).and_return(@address_book)
35
- @list_format.should_receive(:process).and_return("all the names")
36
- @output.should_receive(:line).with("all the names")
34
+ expect(@storage).to receive(:load_address_book).and_return(@address_book)
35
+ expect(@list_format).to receive(:process).and_return("all the names")
36
+ expect(@output).to receive(:line).with("all the names")
37
37
  @input.arguments = []
38
38
  @command.execute(@input, @output)
39
39
  end
40
40
 
41
41
  it "should show the specified contact's name if no name is given" do
42
- @storage.should_receive(:require_contact).and_return(@contact)
43
- @show_format.should_receive(:process).and_return("John Doe")
44
- @output.should_receive(:line).with("John Doe")
42
+ expect(@storage).to receive(:require_contact).and_return(@contact)
43
+ expect(@show_format).to receive(:process).and_return("John Doe")
44
+ expect(@output).to receive(:line).with("John Doe")
45
45
  @input.arguments = ["jim"]
46
- @command.execute(@input, @output).should eq true
46
+ expect(@command.execute(@input, @output)).to eq true
47
47
  end
48
48
 
49
49
  it "should not output anything if there's nothing to show" do
50
- @storage.should_receive(:require_contact).and_return(@contact)
51
- @show_format.should_receive(:process).and_return("")
50
+ expect(@storage).to receive(:require_contact).and_return(@contact)
51
+ expect(@show_format).to receive(:process).and_return("")
52
52
  @input.arguments = ["jim"]
53
- @command.execute(@input, @output).should eq false
53
+ expect(@command.execute(@input, @output)).to eq false
54
54
  end
55
55
 
56
56
  it "should change the contact's name if a name is given" do
57
- @storage.should_receive(:require_contact).and_return(@contact)
58
- @name_service.should_receive(:update).with(@contact.name, {
57
+ expect(@storage).to receive(:require_contact).and_return(@contact)
58
+ expect(@name_service).to receive(:update).with(@contact.name, {
59
59
  :full => "Jim Jamieson"
60
60
  })
61
- @storage.should_receive(:save_contact)
61
+ expect(@storage).to receive(:save_contact)
62
62
  @input.arguments = ["jim", "Jim Jamieson"]
63
63
  @command.execute(@input, @output)
64
64
  end
65
65
 
66
66
  it "should change the contact's name if a name is given" do
67
- @storage.should_receive(:require_contact).and_return(@contact)
68
- @name_service.should_receive(:update).with(@contact.name, {
67
+ expect(@storage).to receive(:require_contact).and_return(@contact)
68
+ expect(@name_service).to receive(:update).with(@contact.name, {
69
69
  :family => "Smith"
70
70
  })
71
- @storage.should_receive(:save_contact)
71
+ expect(@storage).to receive(:save_contact)
72
72
  @input.arguments = ["jim"]
73
73
  @input.options = { :family => "Smith" }
74
74
  @command.execute(@input, @output)
@@ -6,7 +6,7 @@ describe Ppl::Command::Nick do
6
6
 
7
7
  describe "#name" do
8
8
  it "should be 'nick'" do
9
- @command.name.should eq "nick"
9
+ expect(@command.name).to eq "nick"
10
10
  end
11
11
  end
12
12
 
@@ -6,7 +6,7 @@ describe Ppl::Command::Org do
6
6
 
7
7
  describe "#name" do
8
8
  it "should be 'org'" do
9
- @command.name.should eq "org"
9
+ expect(@command.name).to eq "org"
10
10
  end
11
11
  end
12
12
 
@@ -6,7 +6,7 @@ describe Ppl::Command::Phone do
6
6
 
7
7
  describe "#name" do
8
8
  it "should be 'phone'" do
9
- @command.name.should eq "phone"
9
+ expect(@command.name).to eq "phone"
10
10
  end
11
11
  end
12
12
 
@@ -20,8 +20,8 @@ describe Ppl::Command::Phone do
20
20
  @show_format = double(Ppl::Format::Contact)
21
21
  @input = Ppl::Application::Input.new
22
22
  @output = double(Ppl::Application::Output)
23
- @storage.stub(:require_contact).and_return(@contact)
24
- @storage.stub(:save_contact)
23
+ allow(@storage).to receive(:require_contact).and_return(@contact)
24
+ allow(@storage).to receive(:save_contact)
25
25
  @command.phone_service = @service
26
26
  @command.storage = @storage
27
27
  @command.list_format = @list_format
@@ -29,40 +29,40 @@ describe Ppl::Command::Phone do
29
29
  end
30
30
 
31
31
  it "should list all phone numbers by default" do
32
- @storage.should_receive(:load_address_book).and_return(@address_book)
33
- @list_format.should_receive(:process)
34
- @output.should_receive(:line)
32
+ expect(@storage).to receive(:load_address_book).and_return(@address_book)
33
+ expect(@list_format).to receive(:process)
34
+ expect(@output).to receive(:line)
35
35
  @command.execute(@input, @output)
36
36
  end
37
37
 
38
38
  it "should show a single contact's numbers if one is specified" do
39
39
  @input.arguments << "jdoe"
40
- @storage.should_receive(:require_contact).and_return(@contact)
41
- @show_format.should_receive(:process)
42
- @output.should_receive(:line)
40
+ expect(@storage).to receive(:require_contact).and_return(@contact)
41
+ expect(@show_format).to receive(:process)
42
+ expect(@output).to receive(:line)
43
43
  @command.execute(@input, @output)
44
44
  end
45
45
 
46
46
  it "should delegate to the service layer to remove a phone number" do
47
47
  @input.arguments = ["jdoe", "01234567890"]
48
48
  @input.options[:delete] = true
49
- @storage.should_receive(:require_contact).and_return(@contact)
50
- @service.should_receive(:remove).with(@contact, "01234567890")
49
+ expect(@storage).to receive(:require_contact).and_return(@contact)
50
+ expect(@service).to receive(:remove).with(@contact, "01234567890")
51
51
  @command.execute(@input, @output)
52
52
  end
53
53
 
54
54
  it "should delegate to the service layer to add a new phone number" do
55
55
  @input.arguments = ["jdoe", "98776332"]
56
- @storage.should_receive(:require_contact).and_return(@contact)
57
- @service.should_receive(:add).with(@contact, "98776332", @input.options)
56
+ expect(@storage).to receive(:require_contact).and_return(@contact)
57
+ expect(@service).to receive(:add).with(@contact, "98776332", @input.options)
58
58
  @command.execute(@input, @output)
59
59
  end
60
60
 
61
61
  it "should delegate to the service layer to update an existing number" do
62
62
  @contact.phone_numbers << Ppl::Entity::PhoneNumber.new("012345678")
63
63
  @input.arguments = ["jdoe", "012345678"]
64
- @storage.should_receive(:require_contact).and_return(@contact)
65
- @service.should_receive(:update).with(@contact, "012345678", {})
64
+ expect(@storage).to receive(:require_contact).and_return(@contact)
65
+ expect(@service).to receive(:update).with(@contact, "012345678", {})
66
66
  @command.execute(@input, @output)
67
67
  end
68
68
 
@@ -26,7 +26,7 @@ describe Ppl::Command::Post do
26
26
 
27
27
  describe "#name" do
28
28
  it "should be 'post'" do
29
- @command.name.should eq "post"
29
+ expect(@command.name).to eq "post"
30
30
  end
31
31
  end
32
32
 
@@ -37,9 +37,9 @@ describe Ppl::Command::Post do
37
37
  before { @input.arguments = [] }
38
38
 
39
39
  it "displays postal address information for the whole address book" do
40
- @storage.should_receive(:load_address_book).and_return(@address_book)
41
- @address_book_format.should_receive(:process).and_return("all the postal addresses")
42
- @output.should_receive(:line).with("all the postal addresses")
40
+ expect(@storage).to receive(:load_address_book).and_return(@address_book)
41
+ expect(@address_book_format).to receive(:process).and_return("all the postal addresses")
42
+ expect(@output).to receive(:line).with("all the postal addresses")
43
43
  @input.arguments = []
44
44
  @command.execute(@input, @output)
45
45
  end
@@ -50,16 +50,16 @@ describe Ppl::Command::Post do
50
50
  before { @input.arguments = ["jim"] }
51
51
 
52
52
  it "shows all of a contact's postal addresses" do
53
- @storage.should_receive(:require_contact).and_return(@contact)
54
- @contact_format.should_receive(:process).and_return("1 Test Road")
55
- @output.should_receive(:line).with("1 Test Road")
56
- @command.execute(@input, @output).should eq true
53
+ expect(@storage).to receive(:require_contact).and_return(@contact)
54
+ expect(@contact_format).to receive(:process).and_return("1 Test Road")
55
+ expect(@output).to receive(:line).with("1 Test Road")
56
+ expect(@command.execute(@input, @output)).to eq true
57
57
  end
58
58
 
59
59
  it "outputs nothing if the contact has no addresses" do
60
- @storage.should_receive(:require_contact).and_return(@contact)
61
- @contact_format.should_receive(:process).and_return("")
62
- @command.execute(@input, @output).should eq false
60
+ expect(@storage).to receive(:require_contact).and_return(@contact)
61
+ expect(@contact_format).to receive(:process).and_return("")
62
+ expect(@command.execute(@input, @output)).to eq false
63
63
  end
64
64
 
65
65
  end
@@ -69,16 +69,16 @@ describe Ppl::Command::Post do
69
69
  before { @input.arguments = ["jim", "home"] }
70
70
 
71
71
  it "shows a single postal address" do
72
- @storage.should_receive(:require_contact).and_return(@contact)
73
- @postal_address_format.should_receive(:process).with(@address).and_return("1 Test Road")
74
- @output.should_receive(:line).with("1 Test Road")
75
- @command.execute(@input, @output).should eq true
72
+ expect(@storage).to receive(:require_contact).and_return(@contact)
73
+ expect(@postal_address_format).to receive(:process).with(@address).and_return("1 Test Road")
74
+ expect(@output).to receive(:line).with("1 Test Road")
75
+ expect(@command.execute(@input, @output)).to eq true
76
76
  end
77
77
 
78
78
  it "raises an error if there's no such address" do
79
79
  @input.arguments[1] = "other"
80
- @storage.should_receive(:require_contact).and_return(@contact)
81
- expect{@command.execute(@input, @output).should eq true}.to raise_error(Ppl::Error::PostalAddressNotFound)
80
+ expect(@storage).to receive(:require_contact).and_return(@contact)
81
+ expect{expect(@command.execute(@input, @output)).to eq true}.to raise_error(Ppl::Error::PostalAddressNotFound)
82
82
  end
83
83
 
84
84
  end
@@ -89,10 +89,10 @@ describe Ppl::Command::Post do
89
89
  before { @input.options = { :delete => true }}
90
90
 
91
91
  it "deletes the postal address" do
92
- @storage.should_receive(:require_contact).and_return(@contact)
93
- @service.should_receive(:remove).with(@contact, "home")
94
- @storage.should_receive(:save_contact)
95
- @command.execute(@input, @output).should eq true
92
+ expect(@storage).to receive(:require_contact).and_return(@contact)
93
+ expect(@service).to receive(:remove).with(@contact, "home")
94
+ expect(@storage).to receive(:save_contact)
95
+ expect(@command.execute(@input, @output)).to eq true
96
96
  end
97
97
 
98
98
  end
@@ -103,10 +103,10 @@ describe Ppl::Command::Post do
103
103
  before { @input.options = { :country => "New Country" }}
104
104
 
105
105
  it "updates the postal address" do
106
- @storage.should_receive(:require_contact).and_return(@contact)
107
- @service.should_receive(:update).with(@contact, "home", {:country => "New Country"})
108
- @storage.should_receive(:save_contact)
109
- @command.execute(@input, @output).should eq true
106
+ expect(@storage).to receive(:require_contact).and_return(@contact)
107
+ expect(@service).to receive(:update).with(@contact, "home", {:country => "New Country"})
108
+ expect(@storage).to receive(:save_contact)
109
+ expect(@command.execute(@input, @output)).to eq true
110
110
  end
111
111
 
112
112
  end
@@ -118,10 +118,10 @@ describe Ppl::Command::Post do
118
118
  before { @input.options = { :street => "123 Swim St" }}
119
119
 
120
120
  it "adds the postal address" do
121
- @storage.should_receive(:require_contact).and_return(@contact)
122
- @service.should_receive(:add).with(@contact, "newaddress", {:street => "123 Swim St"})
123
- @storage.should_receive(:save_contact)
124
- @command.execute(@input, @output).should eq true
121
+ expect(@storage).to receive(:require_contact).and_return(@contact)
122
+ expect(@service).to receive(:add).with(@contact, "newaddress", {:street => "123 Swim St"})
123
+ expect(@storage).to receive(:save_contact)
124
+ expect(@command.execute(@input, @output)).to eq true
125
125
  end
126
126
 
127
127
  end
@@ -13,7 +13,7 @@ describe Ppl::Command::Rm do
13
13
 
14
14
  describe "#name" do
15
15
  it "should be 'rm'" do
16
- @command.name.should eq "rm"
16
+ expect(@command.name).to eq "rm"
17
17
  end
18
18
  end
19
19
 
@@ -25,8 +25,8 @@ describe Ppl::Command::Rm do
25
25
  end
26
26
 
27
27
  it "should delete the given contact" do
28
- @storage.should_receive(:require_contact).and_return(@contact)
29
- @storage.should_receive(:delete_contact).with(@contact)
28
+ expect(@storage).to receive(:require_contact).and_return(@contact)
29
+ expect(@storage).to receive(:delete_contact).with(@contact)
30
30
  @command.execute(@input, @output)
31
31
  end
32
32
 
@@ -15,68 +15,68 @@ describe Ppl::Command::Scrape do
15
15
 
16
16
  describe "#name" do
17
17
  it "should be 'scrape'" do
18
- @command.name.should eq "scrape"
18
+ expect(@command.name).to eq "scrape"
19
19
  end
20
20
  end
21
21
 
22
22
  describe "#execute" do
23
23
 
24
24
  before(:each) do
25
- @input.stdin.stub(:read)
26
- @input.stdin.stub(:reopen)
27
- @input.stdin.stub(:eof?)
28
- @email_scraper.stub(:scrape_contacts).and_return([])
29
- Readline.stub(:readline).and_return("")
30
- @storage.stub(:save_contact)
25
+ allow(@input.stdin).to receive(:read)
26
+ allow(@input.stdin).to receive(:reopen)
27
+ allow(@input.stdin).to receive(:eof?)
28
+ allow(@email_scraper).to receive(:scrape_contacts).and_return([])
29
+ allow(Readline).to receive(:readline).and_return("")
30
+ allow(@storage).to receive(:save_contact)
31
31
  end
32
32
 
33
33
  it "should read input from stdin" do
34
34
  @input.options[:sender] = true
35
- @input.stdin.should_receive(:read)
35
+ expect(@input.stdin).to receive(:read)
36
36
  @command.execute(@input, @output)
37
37
  end
38
38
 
39
39
  it "should pass input to the email scraper" do
40
40
  @input.options[:sender] = true
41
- @email_scraper.should_receive(:scrape_contacts)
41
+ expect(@email_scraper).to receive(:scrape_contacts)
42
42
  @command.execute(@input, @output)
43
43
  end
44
44
 
45
45
  it "shouldn't do any scraping unless told which fields to scrape" do
46
- @email_scraper.should_not_receive(:scrape_contacts)
46
+ expect(@email_scraper).not_to receive(:scrape_contacts)
47
47
  @command.execute(@input, @output)
48
48
  end
49
49
 
50
50
  it "should always save contacts if in quiet mode" do
51
51
  @input.options[:sender] = true
52
52
  @input.options[:quiet] = true
53
- @email_scraper.stub(:scrape_contacts).and_return([@contact])
54
- Readline.should_not_receive(:readline)
55
- @storage.should_receive(:save_contact)
53
+ allow(@email_scraper).to receive(:scrape_contacts).and_return([@contact])
54
+ expect(Readline).not_to receive(:readline)
55
+ expect(@storage).to receive(:save_contact)
56
56
  @command.execute(@input, @output)
57
57
  end
58
58
 
59
59
  it "should reopen stdin to prompt the user" do
60
60
  @input.options[:sender] = true
61
- @input.stdin.should_receive(:eof?).and_return(true)
62
- @input.stdin.should_receive(:reopen)
63
- @email_scraper.stub(:scrape_contacts).and_return([@contact])
61
+ expect(@input.stdin).to receive(:eof?).and_return(true)
62
+ expect(@input.stdin).to receive(:reopen)
63
+ allow(@email_scraper).to receive(:scrape_contacts).and_return([@contact])
64
64
  @command.execute(@input, @output)
65
65
  end
66
66
 
67
67
  it "should save the contact if the user approves" do
68
68
  @input.options[:sender] = true
69
- @email_scraper.stub(:scrape_contacts).and_return([@contact])
70
- Readline.should_receive(:readline).and_return("y")
71
- @storage.should_receive(:save_contact)
69
+ allow(@email_scraper).to receive(:scrape_contacts).and_return([@contact])
70
+ expect(Readline).to receive(:readline).and_return("y")
71
+ expect(@storage).to receive(:save_contact)
72
72
  @command.execute(@input, @output)
73
73
  end
74
74
 
75
75
  it "should not save the contact if the user disapproves" do
76
76
  @input.options[:sender] = true
77
- @email_scraper.stub(:scrape_contacts).and_return([@contact])
78
- Readline.should_receive(:readline).and_return("n")
79
- @storage.should_not_receive(:save_contact)
77
+ allow(@email_scraper).to receive(:scrape_contacts).and_return([@contact])
78
+ expect(Readline).to receive(:readline).and_return("n")
79
+ expect(@storage).not_to receive(:save_contact)
80
80
  @command.execute(@input, @output)
81
81
  end
82
82
 
@@ -85,8 +85,8 @@ describe Ppl::Command::Scrape do
85
85
  contact = Ppl::Entity::Contact.new
86
86
  contact.name = "Test Person"
87
87
  contact.email_addresses << "test@example.org"
88
- @email_scraper.stub(:scrape_contacts).and_return([contact])
89
- Readline.should_receive(:readline).with("Add \"Test Person <test@example.org>\" to your address book [Y/n]? ")
88
+ allow(@email_scraper).to receive(:scrape_contacts).and_return([contact])
89
+ expect(Readline).to receive(:readline).with("Add \"Test Person <test@example.org>\" to your address book [Y/n]? ")
90
90
  @command.execute(@input, @output)
91
91
  end
92
92
 
@@ -8,16 +8,16 @@ describe Ppl::Command::Shell do
8
8
 
9
9
  describe "#name" do
10
10
  it "should be 'shell'" do
11
- @command.name.should eq "shell"
11
+ expect(@command.name).to eq "shell"
12
12
  end
13
13
  end
14
14
 
15
15
  describe "#execute" do
16
16
  it "should read a line of input from stdin" do
17
- Readline.should_receive(:readline)
18
- @command.stub(:welcome_user)
19
- @command.stub(:terminate_gracefully)
20
- @command.execute(@input, @output).should eq true
17
+ expect(Readline).to receive(:readline)
18
+ allow(@command).to receive(:welcome_user)
19
+ allow(@command).to receive(:terminate_gracefully)
20
+ expect(@command.execute(@input, @output)).to eq true
21
21
  end
22
22
  end
23
23
 
@@ -25,73 +25,73 @@ describe Ppl::Command::Shell do
25
25
 
26
26
  before(:each) do
27
27
  @input.stdin = double(IO)
28
- @input.stdin.stub(:tty?) { true }
28
+ allow(@input.stdin).to receive(:tty?) { true }
29
29
  end
30
30
 
31
31
  it "should not show a prompt if stdin isn't a tty" do
32
- @input.stdin.stub(:tty?) { false }
33
- Readline.should_receive(:readline).with("", true)
34
- @command.stub(:welcome_user)
32
+ allow(@input.stdin).to receive(:tty?) { false }
33
+ expect(Readline).to receive(:readline).with("", true)
34
+ allow(@command).to receive(:welcome_user)
35
35
  @command.execute(@input, @output)
36
36
  end
37
37
 
38
38
  it "should show a prompt if stdin is a tty" do
39
- @input.stdin.stub(:tty?) { true }
40
- Readline.should_receive(:readline).with("ppl> ", true)
41
- @command.stub(:welcome_user)
42
- @command.stub(:terminate_gracefully)
39
+ allow(@input.stdin).to receive(:tty?) { true }
40
+ expect(Readline).to receive(:readline).with("ppl> ", true)
41
+ allow(@command).to receive(:welcome_user)
42
+ allow(@command).to receive(:terminate_gracefully)
43
43
  @command.execute(@input, @output)
44
44
  end
45
45
 
46
46
  it "should make a system call with the input from stdin" do
47
- Readline.should_receive(:readline).and_return("email fred")
48
- Readline.should_receive(:readline).and_return(false)
49
- Kernel.should_receive(:system) do |command|
50
- command.should include "email fred"
47
+ expect(Readline).to receive(:readline).and_return("email fred")
48
+ expect(Readline).to receive(:readline).and_return(false)
49
+ expect(Kernel).to receive(:system) do |command|
50
+ expect(command).to include "email fred"
51
51
  end
52
- @command.stub(:welcome_user)
53
- @command.stub(:terminate_gracefully)
54
- @command.execute(@input, @output).should eq true
52
+ allow(@command).to receive(:welcome_user)
53
+ allow(@command).to receive(:terminate_gracefully)
54
+ expect(@command.execute(@input, @output)).to eq true
55
55
  end
56
56
 
57
57
  it "should exit on ctrl+c" do
58
- Readline.should_receive(:readline).and_raise(Interrupt)
59
- @command.stub(:welcome_user)
60
- @command.stub(:terminate_gracefully)
61
- @command.execute(@input, @output).should eq false
58
+ expect(Readline).to receive(:readline).and_raise(Interrupt)
59
+ allow(@command).to receive(:welcome_user)
60
+ allow(@command).to receive(:terminate_gracefully)
61
+ expect(@command.execute(@input, @output)).to eq false
62
62
  end
63
63
 
64
64
  it "should print a final newline on EOF so the user's prompt looks nice" do
65
- @input.stdin.stub(:tty?) { true }
66
- @output.should_receive(:line).with("")
67
- Readline.should_receive(:readline).and_return(false)
68
- @command.stub(:welcome_user)
65
+ allow(@input.stdin).to receive(:tty?) { true }
66
+ expect(@output).to receive(:line).with("")
67
+ expect(Readline).to receive(:readline).and_return(false)
68
+ allow(@command).to receive(:welcome_user)
69
69
  @command.execute(@input, @output)
70
70
  end
71
71
 
72
72
  it "should print a final newline on error so the user's prompt looks nice" do
73
- @input.stdin.stub(:tty?) { true }
74
- @output.should_receive(:line).with("")
75
- @command.stub(:shell).and_raise(Interrupt)
73
+ allow(@input.stdin).to receive(:tty?) { true }
74
+ expect(@output).to receive(:line).with("")
75
+ allow(@command).to receive(:shell).and_raise(Interrupt)
76
76
  @command.execute(@input, @output)
77
77
  end
78
78
 
79
79
  it "should not print a final newline on EOF if stdin isn't a tty" do
80
- @input.stdin.stub(:tty?) { false }
81
- @output.should_not_receive(:line).with("")
82
- Readline.should_receive(:readline).and_return(false)
83
- @command.stub(:welcome_user)
80
+ allow(@input.stdin).to receive(:tty?) { false }
81
+ expect(@output).not_to receive(:line).with("")
82
+ expect(Readline).to receive(:readline).and_return(false)
83
+ allow(@command).to receive(:welcome_user)
84
84
  @command.execute(@input, @output)
85
85
  end
86
86
 
87
87
  it "should print a welcome message on the tty" do
88
- @input.stdin.stub(:tty?) { true }
89
- @output.should_receive(:line) do |line|
90
- line.should include "ppl"
91
- line.should include Ppl::Version
88
+ allow(@input.stdin).to receive(:tty?) { true }
89
+ expect(@output).to receive(:line) do |line|
90
+ expect(line).to include "ppl"
91
+ expect(line).to include Ppl::Version
92
92
  end
93
- Readline.should_receive(:readline).and_return(false)
94
- @command.stub(:terminate_gracefully)
93
+ expect(Readline).to receive(:readline).and_return(false)
94
+ allow(@command).to receive(:terminate_gracefully)
95
95
  @command.execute(@input, @output)
96
96
  end
97
97