Skip to content
Browse files

don't show # empty descriptions on search list

  • Loading branch information...
1 parent 8f1b597 commit 6d9eb4132fe2dfbf96c343ed41595ac36edd5d8a @drnic drnic committed Nov 4, 2009
Showing with 4 additions and 2 deletions.
  1. +1 −1 lib/commands/helpers.rb
  2. +3 −1 spec/helper_spec.rb
View
2 lib/commands/helpers.rb
@@ -466,7 +466,7 @@
longest = longest_name.size + 1
lines = items.map do |item|
cmdstr = "%-#{longest}s" % item["name"]
- if description = item["description"]
+ if (description = item["description"]) && description.length > 0
cmdstr += "# #{description}"
end
cmdstr
View
4 spec/helper_spec.rb
@@ -35,11 +35,13 @@ def self.helper(name, &block)
it "should format an array of hashes with name,description keys" do
list = [{"name" => "aaa", "description" => "description for aaa"},
{"name" => "a long name", "description" => "help"},
- {"name" => "no desc"}]
+ {"name" => "no desc"},
+ {"name" => "empty desc", "description" => ""}]
expected = <<-EOS.gsub(/^ /, '')
aaa # description for aaa
a long name # help
no desc
+ empty desc
EOS
@helper.format_list(list).should == expected.gsub(/\n$/,'')
end

0 comments on commit 6d9eb41

Please sign in to comment.
Something went wrong with that request. Please try again.