Skip to content

Commit

Permalink
Nokogiri::XML.parse() supports argument forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
openbl committed Nov 14, 2024
1 parent 8fba8c8 commit c2f27cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/nokogiri/xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def Reader(string_or_io, url = nil, encoding = nil, options = ParseOptions::STRI

###
# Parse XML. Convenience method for Nokogiri::XML::Document.parse
def parse(thing, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML, &block)
Document.parse(thing, url, encoding, options, &block)
def parse(...)
Document.parse(...)
end

####
Expand Down
13 changes: 13 additions & 0 deletions test/xml/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,13 @@ def test_can_be_closed
end
assert_nil(error.path)
end

it "raises exception on parse error with kwargs" do
error = assert_raises Nokogiri::SyntaxError do
Nokogiri::XML.parse(input, options: parse_options)
end
assert_nil(error.path)
end
end

describe "default options" do
Expand All @@ -1122,6 +1129,12 @@ def test_can_be_closed
Nokogiri::XML.parse(input, nil, nil, parse_options)
end
end

it "raises exception on parse error with kwargs" do
assert_raises Nokogiri::SyntaxError do
Nokogiri::XML.parse(input, options: parse_options)
end
end
end

describe "default options" do
Expand Down

0 comments on commit c2f27cf

Please sign in to comment.