diff options
author | Connor Garvey <connorgarvey@google.com> | 2022-03-10 17:04:15 -0800 |
---|---|---|
committer | Connor Garvey <connorgarvey@google.com> | 2022-03-10 17:04:15 -0800 |
commit | 8ae2eae0bf0b09346589bb57bdb13c86d96b6e0f (patch) | |
tree | c237da22a194f9ae5e0a6af7ae894b5318c92d48 /test/parser_test.rb | |
parent | 0e1d8d0168fc6a6b647cecda0b73d97d1484a563 (diff) | |
download | slop-8ae2eae0bf0b09346589bb57bdb13c86d96b6e0f.tar.gz |
Handle strings containing =
Diffstat (limited to 'test/parser_test.rb')
-rw-r--r-- | test/parser_test.rb | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/test/parser_test.rb b/test/parser_test.rb index b729ee8..bbdc4a9 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -17,16 +17,25 @@ describe Slop::Parser do assert_equal ["-v", "--name", "lee"], @parser.arguments end - it "parses flag=argument" do - @options.integer "-p", "--port" - @result.parser.parse %w(--name=bob -p=123) - assert_equal "bob", @result[:name] - assert_equal 123, @result[:port] + describe "for flag=argument" do + it "parses names and values" do + @options.integer "-p", "--port" + @result.parser.parse %w(--name=bob -p=123) + assert_equal "bob", @result[:name] + assert_equal 123, @result[:port] + end - @options.string "--foo" - @result.parser.parse %w(--foo = =) - assert_equal "=", @result[:foo] - assert_equal %w(=), @result.args + it "treats an = separated by a space as a value" do + @options.string "--foo" + @result.parser.parse %w(--foo = =) + assert_equal "=", @result[:foo] + assert_equal %w(=), @result.args + end + + it "includes = in strings" do + @result.parser.parse(%w(--name=b=b)) + assert_equal "b=b", @result[:name] + end end it "parses flag=''" do |