diff options
-rw-r--r-- | lib/slop/options.rb | 4 | ||||
-rw-r--r-- | test/options_test.rb | 23 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/slop/options.rb b/lib/slop/options.rb index 41913e0..3a1e429 100644 --- a/lib/slop/options.rb +++ b/lib/slop/options.rb @@ -111,6 +111,10 @@ module Slop str << "#{prefix}#{opt.to_s(offset: len)}\n" end + if sep = separators[options.size] + str << "#{sep}\n" + end + str end diff --git a/test/options_test.rb b/test/options_test.rb index 8553fe1..3ef34c5 100644 --- a/test/options_test.rb +++ b/test/options_test.rb @@ -37,7 +37,28 @@ describe Slop::Options do end describe "#separator" do - # TODO: Missing all other specs for #separator + it "appends separators between options in order" do + @options.separator("foo") + @options.on("--foo") + @options.separator("bar") + + assert_equal ["foo", "bar"], @options.separators + end + + it "appends strings to the last separator if no options exist" do + @options.separator("foo") + @options.separator("bar") + + assert_equal ["foo\nbar"], @options.separators + end + + it "includes separators in the help text" do + @options.on("--foo") + @options.separator("bar") + + help = @options.to_s.squeeze(" ") + assert help.end_with?("--foo \nbar\n") + end it "accepts a frozen argument, even when called multiple times for the same option" do @options.separator("foo".freeze) |