diff options
author | Lee Jarvis <leejarvis@fastmail.com> | 2017-11-17 23:20:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-17 23:20:41 +0000 |
commit | d021364d5a2dc3a6b22953be215f332b3fde23b7 (patch) | |
tree | df6800124b3f446afeec07a5198d40607709ff35 | |
parent | 641c537eca68286620c13256f2d85aeb1d116ed4 (diff) | |
parent | 68dcd76d58584c192f202409365350d0b356e391 (diff) | |
download | slop-d021364d5a2dc3a6b22953be215f332b3fde23b7.tar.gz |
Merge pull request #223 from marcandre/separator
Fix separator so it doesn't mutate user data
-rw-r--r-- | lib/slop/options.rb | 2 | ||||
-rw-r--r-- | test/options_test.rb | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/slop/options.rb b/lib/slop/options.rb index 94fc5dd..41913e0 100644 --- a/lib/slop/options.rb +++ b/lib/slop/options.rb @@ -61,7 +61,7 @@ module Slop # the help text. def separator(string) if separators[options.size] - separators.last << "\n#{string}" + separators[-1] += "\n#{string}" else separators[options.size] = string end diff --git a/test/options_test.rb b/test/options_test.rb index bb19210..8553fe1 100644 --- a/test/options_test.rb +++ b/test/options_test.rb @@ -36,6 +36,15 @@ describe Slop::Options do end end + describe "#separator" do + # TODO: Missing all other specs for #separator + + it "accepts a frozen argument, even when called multiple times for the same option" do + @options.separator("foo".freeze) + @options.separator("bar".freeze) + end + end + describe "#method_missing" do it "uses the method name as an option type" do option = @options.string("--name") @@ -86,7 +95,7 @@ describe Slop::Options do describe "custom banner" do it "is prefixed with defined banner" do @options_config = Slop::Options.new({banner: "custom banner"}) - assert_match(/^custom banner/, @options_config.to_s) + assert_match(/^custom banner/, @options_config.to_s) end it "banner is disabled" do @options_config = Slop::Options.new({banner: false}) |