Skip to content

Commit 822eb5e

Browse files
authored
Merge pull request #2735 from ksss/optparse-raise_unknown
Add signature for `OptionParser#raise_unknown`
2 parents f954df9 + 27398b0 commit 822eb5e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

stdlib/optparse/0/optparse.rbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,11 @@ class OptionParser
825825
#
826826
attr_accessor program_name: String
827827

828+
# <!-- rdoc-file=lib/optparse.rb -->
829+
# Whether to raise at unknown option.
830+
#
831+
attr_accessor raise_unknown: boolish
832+
828833
# <!--
829834
# rdoc-file=lib/optparse.rb
830835
# - reject(*args, &blk)

test/stdlib/OptionParser_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ def test_program_name=
201201
assert_send_type "(String) -> String", opt, :program_name=, 'foo'
202202
end
203203

204+
def test_raise_unknown
205+
assert_send_type "() -> boolish", opt, :raise_unknown
206+
end
207+
208+
def test_raise_unknown=
209+
assert_send_type "(boolish) -> boolish", opt, :raise_unknown=, true
210+
end
211+
204212
def test_reject
205213
assert_send_type '(Class) -> void', opt, :reject, Class.new
206214
end

0 commit comments

Comments
 (0)