summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlle Jonsson <olle.jonsson@gmail.com>2019-01-20 18:22:18 +0100
committerGitHub <noreply@github.com>2019-01-20 18:22:18 +0100
commit61d25768adc905e898c369160e26d02d9921f8b3 (patch)
tree27156f491f45ce58119837ba894b6041fcf9df85
parent7037ef0867bf6da9149121b3efa3e80e6a70732c (diff)
parent0c9175428655993b994d7fd5988002c437ab56a6 (diff)
downloadslop-61d25768adc905e898c369160e26d02d9921f8b3.tar.gz
Merge pull request #238 from tmatilai/empty-separator
Allow calling `Options#separator` without args, defaulting to an empty string
-rw-r--r--lib/slop/options.rb2
-rw-r--r--test/options_test.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/slop/options.rb b/lib/slop/options.rb
index 3a1e429..009964a 100644
--- a/lib/slop/options.rb
+++ b/lib/slop/options.rb
@@ -59,7 +59,7 @@ module Slop
# Add a separator between options. Used when displaying
# the help text.
- def separator(string)
+ def separator(string = "")
if separators[options.size]
separators[-1] += "\n#{string}"
else
diff --git a/test/options_test.rb b/test/options_test.rb
index 3ef34c5..f816b74 100644
--- a/test/options_test.rb
+++ b/test/options_test.rb
@@ -64,6 +64,12 @@ describe Slop::Options do
@options.separator("foo".freeze)
@options.separator("bar".freeze)
end
+
+ it "defaults to empty string" do
+ @options.separator
+
+ assert_equal [""], @options.separators
+ end
end
describe "#method_missing" do