summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKyrylo Silin <kyrylosilin@gmail.com>2012-12-23 13:34:43 +0200
committerKyrylo Silin <kyrylosilin@gmail.com>2012-12-23 13:34:43 +0200
commitad20e3b5b42210231e7aa6664582e02d46662246 (patch)
treeeceebba0f795b40541dd9194c0c8e22cb63359ee /test
parent2e7165230be95906963b600216e0712edbc8e423 (diff)
downloadslop-ad20e3b5b42210231e7aa6664582e02d46662246.tar.gz
Don't always append global/default headers
Invokations of `global` or `default` methods with bare blocks (that is, without option declarations) appends to the `helps` local variable unwanted information, which results in this: % my_cli_app --help Global options Other options % Fix it by checking whether global or default options, actually, have any options defined. Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/commands_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/commands_test.rb b/test/commands_test.rb
index 174dcf2..6721400 100644
--- a/test/commands_test.rb
+++ b/test/commands_test.rb
@@ -13,6 +13,16 @@ class CommandsTest < TestCase
add_callback(:empty) { 'version 1' }
end
end
+
+ @empty_commands = Slop::Commands.new do
+ default do
+ end
+
+ global do
+ end
+
+ on 'verbose'
+ end
end
test "it nests instances of Slop" do
@@ -75,6 +85,10 @@ class CommandsTest < TestCase
assert_kind_of Slop, @commands.global
end
+ test "empty default/global blocks don't add their titles in the help output" do
+ assert_empty @empty_commands.to_s
+ end
+
test "parse does nothing when there's nothing to parse" do
assert @commands.parse []
end