From 0c9175428655993b994d7fd5988002c437ab56a6 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Sun, 20 Jan 2019 14:54:09 +0200 Subject: Allow calling `Options#separator` without args, defaulting to an empty string It's clear that we want an empty line when calling `opts.separator` without arguments. Leave the examples in the Readme still for a while with the empty string to avoid confusion when using older versions. --- lib/slop/options.rb | 2 +- test/options_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1