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 authored and flavorjones committed Dec 8, 2024
1 parent 9d3141a commit 9435520
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/nokogiri/xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

module Nokogiri
class << self
###
# Parse XML. Convenience method for Nokogiri::XML::Document.parse
# Convenience method for Nokogiri::XML::Document.parse
def XML(...)
Nokogiri::XML::Document.parse(...)
end
Expand All @@ -23,10 +22,9 @@ def Reader(...)
Reader.new(...)
end

###
# 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)
# Convenience method for Nokogiri::XML::Document.parse
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 9435520

Please sign in to comment.