summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2014-11-19 16:54:45 +0000
committerLee Jarvis <ljjarvis@gmail.com>2014-11-19 16:57:05 +0000
commitb2a7405975debde3d0344d348bc1d56aff37bdc2 (patch)
treec417a6914bfe849304ecb85a9db646a1dd3cfb3f /test
parent1264729e19ee69b8ff04c3b6c2ab4650e34b4067 (diff)
downloadslop-b2a7405975debde3d0344d348bc1d56aff37bdc2.tar.gz
Handle short grouped flags
Diffstat (limited to 'test')
-rw-r--r--test/parser_test.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/parser_test.rb b/test/parser_test.rb
index a2cd3a5..8fa85f2 100644
--- a/test/parser_test.rb
+++ b/test/parser_test.rb
@@ -4,7 +4,7 @@ describe Slop::Parser do
before do
@options = Slop::Options.new
@verbose = @options.bool "-v", "--verbose"
- @name = @options.string "--name"
+ @name = @options.string "-n", "--name"
@unused = @options.string "--unused"
@parser = Slop::Parser.new(@options)
@result = @parser.parse %w(foo -v --name lee argument)
@@ -32,6 +32,17 @@ describe Slop::Parser do
assert_equal true, @result.quiet?
assert_equal true, @result.verbose?
end
+
+ it "sends the argument to the last flag" do
+ @result.parser.reset.parse %w(-qvn foo)
+ assert_equal "foo", @result[:name]
+ end
+
+ it "doesn't screw up single hyphen long options" do
+ @options.string "-host"
+ @result.parser.reset.parse %w(-host localhost)
+ assert_equal "localhost", @result[:host]
+ end
end
describe "#used_options" do