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
@@ -14,7 +14,7 @@ describe Ppl::Application::Command do
14
14
  it "should accept a storage adapter" do
15
15
  storage = double(Ppl::Adapter::Storage)
16
16
  @command.storage = storage
17
- @command.storage.should be storage
17
+ expect(@command.storage).to be storage
18
18
  end
19
19
  end
20
20
 
@@ -30,7 +30,7 @@ describe Ppl::Application::Command do
30
30
  add_property :some_property
31
31
  some_property "a value"
32
32
  end
33
- TestCommand456.some_property.should eq "a value"
33
+ expect(TestCommand456.some_property).to eq "a value"
34
34
  end
35
35
 
36
36
  it "should expose properties as instance variables too" do
@@ -39,7 +39,7 @@ describe Ppl::Application::Command do
39
39
  some_property "a value"
40
40
  end
41
41
  instance = TestCommand789.new
42
- instance.some_property.should eq "a value"
42
+ expect(instance.some_property).to eq "a value"
43
43
  end
44
44
 
45
45
  it "should allow properties to be overwritten by instance variables" do
@@ -49,21 +49,21 @@ describe Ppl::Application::Command do
49
49
  end
50
50
  instance = TestCommand901.new
51
51
  instance.some_property = "different"
52
- instance.some_property.should eq "different"
52
+ expect(instance.some_property).to eq "different"
53
53
  end
54
54
  end
55
55
 
56
56
  describe "#name=" do
57
57
  it "should allow the name to be set as an instance variable" do
58
58
  @command.name = "testing"
59
- @command.name.should eq "testing"
59
+ expect(@command.name).to eq "testing"
60
60
  end
61
61
  end
62
62
 
63
63
  describe "#description=" do
64
64
  it "should allow the description to be set as an instance variable" do
65
65
  @command.description = "testing"
66
- @command.description.should eq "testing"
66
+ expect(@command.description).to eq "testing"
67
67
  end
68
68
  end
69
69
 
@@ -73,7 +73,7 @@ describe Ppl::Application::Command do
73
73
  name "new_for_test"
74
74
  end
75
75
  command = TestCommand123.new
76
- command.name.should eq "new_for_test"
76
+ expect(command.name).to eq "new_for_test"
77
77
  end
78
78
  end
79
79
 
@@ -83,7 +83,7 @@ describe Ppl::Application::Command do
83
83
  description "desc_for_test"
84
84
  end
85
85
  command = TestCommand123.new
86
- command.description.should eq "desc_for_test"
86
+ expect(command.description).to eq "desc_for_test"
87
87
  end
88
88
  end
89
89
 
@@ -16,23 +16,23 @@ describe Ppl::Application::CommandSuite do
16
16
  describe "#add_command" do
17
17
  it "should accept a command" do
18
18
  @command_suite.add_command(Ppl::Application::Command.new)
19
- @command_suite.count.should be 3
19
+ expect(@command_suite.count).to be 3
20
20
  end
21
21
  end
22
22
 
23
23
  describe "#find_command" do
24
24
  it "should find a command matching the given name" do
25
- @command_suite.find_command("foo").should be @foo_command
25
+ expect(@command_suite.find_command("foo")).to be @foo_command
26
26
  end
27
27
  it "should return nil if no commands match the given name" do
28
- @command_suite.find_command("baz").should be nil
28
+ expect(@command_suite.find_command("baz")).to be nil
29
29
  end
30
30
  end
31
31
 
32
32
  describe "#each" do
33
33
  it "should yield commands" do
34
- @command_suite
35
- .should_receive(:each)
34
+ expect(@command_suite)
35
+ .to receive(:each)
36
36
  .and_yield(@foo_command)
37
37
  .and_yield(@bar_command)
38
38
  @command_suite.each do |c| end
@@ -42,8 +42,8 @@ describe Ppl::Application::CommandSuite do
42
42
  describe "#sort_by_name" do
43
43
  it "should sort the commands alphabetically by name" do
44
44
  @command_suite.sort_by_name
45
- @command_suite[0].name.should eq "bar"
46
- @command_suite[1].name.should eq "foo"
45
+ expect(@command_suite[0].name).to eq "bar"
46
+ expect(@command_suite[1].name).to eq "foo"
47
47
  end
48
48
  end
49
49
 
@@ -11,44 +11,44 @@ describe Ppl::Application::Configuration do
11
11
 
12
12
  describe "#address_book_path" do
13
13
  it "should default to the current working directory" do
14
- @config.address_book_path.should eq Dir.pwd
14
+ expect(@config.address_book_path).to eq Dir.pwd
15
15
  end
16
16
  it "should be configurable by the user's config file" do
17
- @config.stub(:user_configuration) do
17
+ allow(@config).to receive(:user_configuration) do
18
18
  {"address book" => {"path" => "/contacts"}}
19
19
  end
20
- @config.address_book_path.should eq "/contacts"
20
+ expect(@config.address_book_path).to eq "/contacts"
21
21
  end
22
22
  end
23
23
 
24
24
  describe "#aliases" do
25
25
  it "should return a hash" do
26
- @config.aliases.should be_a(Hash)
26
+ expect(@config.aliases).to be_a(Hash)
27
27
  end
28
28
  end
29
29
 
30
30
  describe "#color_enabled" do
31
31
 
32
32
  it "should return true if color is explicitly enabled" do
33
- @config.stub(:user_configuration).and_return({
33
+ allow(@config).to receive(:user_configuration).and_return({
34
34
  "color" => {
35
35
  "cmd" => "true",
36
36
  },
37
37
  })
38
- @config.color_enabled("cmd").should eq true
38
+ expect(@config.color_enabled("cmd")).to eq true
39
39
  end
40
40
 
41
41
  it "should return false if color is not explicitly enabled" do
42
- @config.color_enabled("cmd").should eq false
42
+ expect(@config.color_enabled("cmd")).to eq false
43
43
  end
44
44
 
45
45
  it "should return false if color is explicitly disabled" do
46
- @config.stub(:user_configuration).and_return({
46
+ allow(@config).to receive(:user_configuration).and_return({
47
47
  "color" => {
48
48
  "cmd" => "false",
49
49
  },
50
50
  })
51
- @config.color_enabled("cmd").should eq false
51
+ expect(@config.color_enabled("cmd")).to eq false
52
52
  end
53
53
 
54
54
  end
@@ -56,8 +56,8 @@ describe Ppl::Application::Configuration do
56
56
  describe "#command_colors" do
57
57
 
58
58
  before(:each) do
59
- @config.stub(:color_enabled).and_return(true)
60
- @config.stub(:user_configuration).and_return({
59
+ allow(@config).to receive(:color_enabled).and_return(true)
60
+ allow(@config).to receive(:user_configuration).and_return({
61
61
  "color \"ls\"" => {
62
62
  "id" => "blue",
63
63
  },
@@ -65,19 +65,19 @@ describe Ppl::Application::Configuration do
65
65
  end
66
66
 
67
67
  it "should return the colors configured for the given command" do
68
- @config.command_colors("ls").should eq({
68
+ expect(@config.command_colors("ls")).to eq({
69
69
  "id" => "blue",
70
70
  })
71
71
  end
72
72
 
73
73
  it "should return an empty hash if colors aren't enabled for the command" do
74
- @config.stub(:color_enabled).and_return(false)
75
- @config.command_colors("ls").should eq({})
74
+ allow(@config).to receive(:color_enabled).and_return(false)
75
+ expect(@config.command_colors("ls")).to eq({})
76
76
  end
77
77
 
78
78
  it "should return nil if no colors are configured for the given command" do
79
- @config.stub(:user_configuration).and_return({})
80
- @config.command_colors("show").should eq(nil)
79
+ allow(@config).to receive(:user_configuration).and_return({})
80
+ expect(@config.command_colors("show")).to eq(nil)
81
81
  end
82
82
 
83
83
  end
@@ -6,13 +6,13 @@ describe Ppl::Application::Input do
6
6
 
7
7
  describe "#arguments" do
8
8
  it "should be an array" do
9
- @input.arguments.should be_an(Array)
9
+ expect(@input.arguments).to be_an(Array)
10
10
  end
11
11
  end
12
12
 
13
13
  describe "#options" do
14
14
  it "should be a hash" do
15
- @input.options.should be_a(Hash)
15
+ expect(@input.options).to be_a(Hash)
16
16
  end
17
17
  end
18
18
 
@@ -20,35 +20,35 @@ describe Ppl::Application::Router do
20
20
  describe "#default=" do
21
21
  it "should accept the name of the default command" do
22
22
  @router.default = "one"
23
- @router.default.should eq "one"
23
+ expect(@router.default).to eq "one"
24
24
  end
25
25
  end
26
26
 
27
27
  describe "#route" do
28
28
 
29
29
  it "should return the command whose name matches the given argument" do
30
- @router.route("two").should be @cmd_two
30
+ expect(@router.route("two")).to be @cmd_two
31
31
  end
32
32
 
33
33
  it "should return nil if no matching command can be found" do
34
- @router.route("three").should be nil
34
+ expect(@router.route("three")).to be nil
35
35
  end
36
36
 
37
37
  it "should fall back to the default command if the given one isn't found" do
38
38
  @router.default = "one"
39
- @router.route("three").should be @cmd_one
39
+ expect(@router.route("three")).to be @cmd_one
40
40
  end
41
41
 
42
42
  it "should apply the aliases if the argument doesn't match a command" do
43
43
  @router.aliases = {"t" => "two"}
44
- @router.route("t").should be @cmd_two
44
+ expect(@router.route("t")).to be @cmd_two
45
45
  end
46
46
 
47
47
  it "should return a Ppl::Command::External if the input matches a bang alias" do
48
- @external.should_receive(:name=).with("t")
49
- @external.should_receive(:command=).with("two")
48
+ expect(@external).to receive(:name=).with("t")
49
+ expect(@external).to receive(:command=).with("two")
50
50
  @router.aliases = {"t" => "!two"}
51
- @router.route("t").should be @external
51
+ expect(@router.route("t")).to be @external
52
52
  end
53
53
 
54
54
  end
@@ -15,94 +15,94 @@ describe Ppl::Application::Shell do
15
15
 
16
16
  it "should return false if the given command isn't found" do
17
17
  @input.arguments = ["foo"]
18
- @router
19
- .should_receive(:route)
18
+ expect(@router)
19
+ .to receive(:route)
20
20
  .with("foo")
21
21
  .and_return(nil)
22
- @shell.run(@input, @output).should eq false
22
+ expect(@shell.run(@input, @output)).to eq false
23
23
  end
24
24
 
25
25
  it "should execute the given command" do
26
26
  @input.arguments = ["foo"]
27
- @router
28
- .should_receive(:route)
27
+ expect(@router)
28
+ .to receive(:route)
29
29
  .with("foo")
30
30
  .and_return(@command)
31
31
 
32
- @command.should_receive(:options)
33
- @command
34
- .should_receive(:execute)
32
+ expect(@command).to receive(:options)
33
+ expect(@command)
34
+ .to receive(:execute)
35
35
  .and_return(true)
36
36
 
37
- @shell.run(@input, @output).should eq true
37
+ expect(@shell.run(@input, @output)).to eq true
38
38
  end
39
39
 
40
40
  it "should not pass the command name in the input to the command itself" do
41
41
  @input.arguments = ["mv", "foo", "bar"]
42
- @router
43
- .should_receive(:route)
42
+ expect(@router)
43
+ .to receive(:route)
44
44
  .with("mv")
45
45
  .and_return(@command)
46
46
 
47
- @command.should_receive(:options)
48
- @command.should_receive(:execute) do |input, output|
49
- input.arguments.should eq ["foo", "bar"]
47
+ expect(@command).to receive(:options)
48
+ expect(@command).to receive(:execute) do |input, output|
49
+ expect(input.arguments).to eq ["foo", "bar"]
50
50
  end
51
51
  @shell.run(@input, @output)
52
52
  end
53
53
 
54
54
  it "should return false if the command throws an exception" do
55
- @command.should_receive(:options)
56
- @command
57
- .should_receive(:execute)
55
+ expect(@command).to receive(:options)
56
+ expect(@command)
57
+ .to receive(:execute)
58
58
  .and_raise(StandardError)
59
59
 
60
- @router
61
- .should_receive(:route)
60
+ expect(@router)
61
+ .to receive(:route)
62
62
  .and_return(@command)
63
63
 
64
- @output.should_receive(:error)
64
+ expect(@output).to receive(:error)
65
65
 
66
66
  @shell.run(@input, @output)
67
67
  end
68
68
 
69
69
  it "should not do any option parsing for Ppl::Command::External instances" do
70
70
  external = Ppl::Command::External.new("ls", "ls", "List directory contents")
71
- external.stub(:execute).and_return(true)
72
- @shell.should_receive(:select_command).and_return(external)
73
- external.should_not_receive(:options)
71
+ allow(external).to receive(:execute).and_return(true)
72
+ expect(@shell).to receive(:select_command).and_return(external)
73
+ expect(external).not_to receive(:options)
74
74
  @shell.run(@input, @output)
75
75
  end
76
76
 
77
77
  it "should send exception messages to stderr" do
78
- @command.should_receive(:options)
79
- @command.should_receive(:execute) { raise "Pool's Closed" }
80
- @router.should_receive(:route).and_return(@command)
81
- @output.should_receive(:error).with("ppl: Pool's Closed")
78
+ expect(@command).to receive(:options)
79
+ expect(@command).to receive(:execute) { raise "Pool's Closed" }
80
+ expect(@router).to receive(:route).and_return(@command)
81
+ expect(@output).to receive(:error).with("ppl: Pool's Closed")
82
82
  @shell.run(@input, @output)
83
83
  end
84
84
 
85
85
  it "should handle ContactNotFound errors nicely" do
86
- @command.stub(:options)
87
- @command.should_receive(:execute) { raise Ppl::Error::ContactNotFound, "example" }
88
- @router.should_receive(:route).and_return(@command)
89
- @output.should_receive(:error).with("ppl: Contact 'example' not found")
86
+ allow(@command).to receive(:options)
87
+ expect(@command).to receive(:execute) { raise Ppl::Error::ContactNotFound, "example" }
88
+ expect(@router).to receive(:route).and_return(@command)
89
+ expect(@output).to receive(:error).with("ppl: Contact 'example' not found")
90
90
  @shell.run(@input, @output)
91
91
  end
92
92
 
93
93
  it "should handle CompletionNotFound errors nicely" do
94
- @command.stub(:options)
95
- @command.should_receive(:execute) { raise Ppl::Error::CompletionNotFound, "example" }
96
- @router.should_receive(:route).and_return(@command)
97
- @output.should_receive(:error).with("ppl: No completion function available for 'example'")
94
+ allow(@command).to receive(:options)
95
+ expect(@command).to receive(:execute) { raise Ppl::Error::CompletionNotFound, "example" }
96
+ expect(@router).to receive(:route).and_return(@command)
97
+ expect(@output).to receive(:error).with("ppl: No completion function available for 'example'")
98
98
  @shell.run(@input, @output)
99
99
  end
100
100
 
101
101
  it "should handle PostalAddressNotFound errors nicely" do
102
- @command.stub(:options)
103
- @command.should_receive(:execute) { raise Ppl::Error::PostalAddressNotFound, "example" }
104
- @router.should_receive(:route).and_return(@command)
105
- @output.should_receive(:error).with("ppl: Postal address 'example' not found")
102
+ allow(@command).to receive(:options)
103
+ expect(@command).to receive(:execute) { raise Ppl::Error::PostalAddressNotFound, "example" }
104
+ expect(@router).to receive(:route).and_return(@command)
105
+ expect(@output).to receive(:error).with("ppl: Postal address 'example' not found")
106
106
  @shell.run(@input, @output)
107
107
  end
108
108
 
@@ -12,7 +12,7 @@ describe Ppl::Command::Add do
12
12
 
13
13
  describe "#name" do
14
14
  it "should be 'add'" do
15
- @command.name.should eq "add"
15
+ expect(@command.name).to eq "add"
16
16
  end
17
17
  end
18
18
 
@@ -28,12 +28,12 @@ describe Ppl::Command::Add do
28
28
  end
29
29
 
30
30
  it "should save a new contact" do
31
- @storage.should_receive(:save_contact) do |contact|
32
- contact.id.should eq "john"
33
- contact.name.should be_a(Ppl::Entity::Name)
31
+ expect(@storage).to receive(:save_contact) do |contact|
32
+ expect(contact.id).to eq "john"
33
+ expect(contact.name).to be_a(Ppl::Entity::Name)
34
34
  end
35
- @name_service
36
- .should_receive(:parse)
35
+ expect(@name_service)
36
+ .to receive(:parse)
37
37
  .with("John Doe")
38
38
  .and_return(Ppl::Entity::Name.new)
39
39
  @input.arguments = ["john", "John Doe"]
@@ -15,24 +15,24 @@ describe Ppl::Command::Age do
15
15
 
16
16
  describe "#name" do
17
17
  it "should be 'age'" do
18
- @command.name.should eq "age"
18
+ expect(@command.name).to eq "age"
19
19
  end
20
20
  end
21
21
 
22
22
  describe "#execute" do
23
23
 
24
24
  it "should list contacts' ages if no arguments are given" do
25
- @storage.should_receive(:load_address_book)
26
- @list_format.should_receive(:process)
27
- @output.should_receive(:line)
25
+ expect(@storage).to receive(:load_address_book)
26
+ expect(@list_format).to receive(:process)
27
+ expect(@output).to receive(:line)
28
28
  @command.execute(@input, @output)
29
29
  end
30
30
 
31
31
  it "should show a single contact's ages if one is specified" do
32
32
  @input.arguments = ["jdoe"]
33
- @storage.should_receive(:require_contact)
34
- @show_format.should_receive(:process)
35
- @output.should_receive(:line)
33
+ expect(@storage).to receive(:require_contact)
34
+ expect(@show_format).to receive(:process)
35
+ expect(@output).to receive(:line)
36
36
  @command.execute(@input, @output)
37
37
  end
38
38