Skip to content

Commit

Permalink
Fixed tests to account for new behavior & added new commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
akhoury6 committed Apr 18, 2024
1 parent 07e97f0 commit 1809e89
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/optimist/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -565,19 +565,19 @@ def test_short_options_with_multiple_options
assert_equal [], @p.leftovers
end

def test_short_options_with_multiple_options_does_not_affect_flags_type
def test_short_options_with_multiple_options_flag_types_get_counted
@p.opt :xarg, "desc", :short => "-x", :type => :flag, :multi => true

opts = @p.parse %w(-x a)
assert_equal true, opts[:xarg]
assert_equal 1, opts[:xarg]
assert_equal %w(a), @p.leftovers

opts = @p.parse %w(-x a -x b)
assert_equal true, opts[:xarg]
assert_equal 2, opts[:xarg]
assert_equal %w(a b), @p.leftovers

opts = @p.parse %w(-xx a -x b)
assert_equal true, opts[:xarg]
assert_equal 3, opts[:xarg]
assert_equal %w(a b), @p.leftovers
end

Expand Down Expand Up @@ -1116,12 +1116,18 @@ def test_accepts_arguments_with_spaces
assert_equal 0, @p.leftovers.size
end

def test_multi_args_default_to_empty_array
@p.opt :arg1, "arg", :multi => true
def test_multi_args_with_specified_type_defaults_to_empty_array
@p.opt :arg1, "arg", :type => :string, :multi => true
opts = @p.parse []
assert_equal [], opts[:arg1]
end

def test_multi_args_with_type_flag_defaults_to_zero
@p.opt :arg1, "arg", :multi => true
opts = @p.parse []
assert_equal 0, opts[:arg1]
end

def test_simple_interface_handles_help
assert_stdout(/Options:/) do
assert_raises(SystemExit) do
Expand Down

0 comments on commit 1809e89

Please sign in to comment.