mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
[ruby/optparse] Fix the test failure i ruby/ruby
```
$ make test-all TESTS=test/optparse/
...
[148/178] TestOptionParserDidYouMean#test_raise_unknown = 0.00 s
1) Failure:
TestOptionParserDidYouMean#test_raise_unknown [/home/mame/work/ruby/test/optparse/test_optparse.rb:106]:
<["--bar"]> expected but was
<[]>.
```
In the old test/unit (bundled in ruby/ruby), when a test class inherits from
another test class, the child class runs all the tests defined in the parent
class.
However, it looks like the new test/unit does not do so. This is because the
test failure does not occur in ruby/optparse.
As a tentative solution, this changes the option names in TestOptionParser to
avoid the name conflict with TestOptionParserDidYouMean.
fee86ef7a4
This commit is contained in:
parent
b649850d4a
commit
f3ad68dd16
1 changed files with 3 additions and 3 deletions
|
@ -99,14 +99,14 @@ class TestOptionParser < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_raise_unknown
|
def test_raise_unknown
|
||||||
@opt.def_option('--foo [ARG]') {|arg| @foo = arg}
|
@opt.def_option('--my-foo [ARG]') {|arg| @foo = arg}
|
||||||
assert @opt.raise_unknown
|
assert @opt.raise_unknown
|
||||||
|
|
||||||
@opt.raise_unknown = false
|
@opt.raise_unknown = false
|
||||||
assert_equal(%w[--bar], @opt.parse(%w[--foo --bar]))
|
assert_equal(%w[--my-bar], @opt.parse(%w[--my-foo --my-bar]))
|
||||||
assert_nil(@foo)
|
assert_nil(@foo)
|
||||||
|
|
||||||
assert_equal(%w[--bar], @opt.parse(%w[--foo x --bar]))
|
assert_equal(%w[--my-bar], @opt.parse(%w[--my-foo x --my-bar]))
|
||||||
assert_equal("x", @foo)
|
assert_equal("x", @foo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue