Skip to content

Commit

Permalink
test DocstringParser warnings for unknown delegated reference params
Browse files Browse the repository at this point in the history
  • Loading branch information
notEthan committed Mar 7, 2023
1 parent a802e4c commit e2bf8e5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec/docstring_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,42 @@ def foo(a) end
eof
end

it "does warn about invalid named reference parameters without a splat" do
expect(log).to receive(:warn).with(/@param tag has unknown parameter name: notaparam/)
YARD.parse_string <<-eof
# @param notaparam (see #elsewhere)
def foo(a) end
eof
end

it "does not warn about unknown named parameters that are delegated" do
expect(log).not_to receive(:warn).with(/@param tag has unknown parameter name: notaparam/)
YARD.parse_string <<-eof
# @param notaparam (see #elsewhere)
def foo(*a) end
eof
end

it "does not warn about unknown named delegated parameters from ref tag list" do
expect(log).not_to receive(:warn).with(/@param tag has unknown parameter name: barparam/)
YARD.parse_string <<-eof
# @param barparam
def bar(barparam) end
# @param (see #bar)
def foo(*a) end
eof
end

it "does warn about unknown named delegated parameters from ref tag list without splat" do
expect(log).to receive(:warn).with(/@param tag has unknown parameter name: barparam/)
YARD.parse_string <<-eof
# @param barparam
def bar(barparam) end
# @param (see #bar)
def foo(a) end
eof
end

it "warns about invalid named parameters on @!method directives" do
expect(log).to receive(:warn).with(/#foo @param tag has unknown parameter name: notaparam/)
YARD.parse_string <<-eof
Expand Down

0 comments on commit e2bf8e5

Please sign in to comment.