diff options
author | Lee Jarvis <leejarvis@fastmail.com> | 2022-03-26 08:58:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-26 08:58:45 +0000 |
commit | 63d69edc1642589082306da5abc3bcf2a1df2ef7 (patch) | |
tree | c237da22a194f9ae5e0a6af7ae894b5318c92d48 /test | |
parent | 0e1d8d0168fc6a6b647cecda0b73d97d1484a563 (diff) | |
parent | 8ae2eae0bf0b09346589bb57bdb13c86d96b6e0f (diff) | |
download | slop-63d69edc1642589082306da5abc3bcf2a1df2ef7.tar.gz |
Merge pull request #275 from ConnorWGarvey/equals
Handle strings containing =
Diffstat (limited to 'test')
-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 |