summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Jarvis <lee@jarvis.co>2012-04-23 11:28:16 +0100
committerLee Jarvis <lee@jarvis.co>2012-04-23 11:28:16 +0100
commit622e953bad4087311cf6760b49a0641b3323b573 (patch)
tree4b508fd921796a934960fb530440954c723ea28f
parent337ee6af5309cfcecfbace96d0d3c039c05d0698 (diff)
downloadslop-622e953bad4087311cf6760b49a0641b3323b573.tar.gz
ensure separators arent replacing existing separators
closes #61
-rw-r--r--lib/slop.rb6
-rw-r--r--test/slop_test.rb3
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/slop.rb b/lib/slop.rb
index 143c296..026f64b 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -332,7 +332,11 @@ class Slop
#
# text - The String text to print.
def separator(text)
- @separators[options.size] = text
+ if @separators[options.size]
+ @separators[options.size] << "\n#{text}"
+ else
+ @separators[options.size] = text
+ end
end
# Print a handy Slop help string.
diff --git a/test/slop_test.rb b/test/slop_test.rb
index bd00444..4195528 100644
--- a/test/slop_test.rb
+++ b/test/slop_test.rb
@@ -291,9 +291,10 @@ class SlopTest < TestCase
opts = Slop.new do
on :foo
separator "hello"
+ separator "world"
on :bar
end
- assert_equal " --foo \nhello\n --bar ", opts.help
+ assert_equal " --foo \nhello\nworld\n --bar ", opts.help
end
test "printing help with :help => true" do