From 9d68777d2a02c90a5b36fae894f390a01094615b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 12 May 2022 11:37:15 -0300 Subject: [PATCH 1/2] Fix XML formatting to get Nokogiri tests passing The mis-formatting was causing this test that was recently added to fail: 1) Error: Recurly::AddOn::.find#test_0005_must return an addon with percentage-tiered-pricing and usage_timeframe when available: Recurly::XML::ParseError: Recurly::XML::ParseError ./recurly-client-ruby/lib/recurly/xml/nokogiri.rb:7:in `rescue in initialize' ./recurly-client-ruby/lib/recurly/xml/nokogiri.rb:4:in `initialize' ./recurly-client-ruby/lib/recurly/xml.rb:61:in `initialize' ./recurly-client-ruby/lib/recurly/resource/pager.rb:290:in `new' ./recurly-client-ruby/lib/recurly/resource/pager.rb:290:in `load_from' ./recurly-client-ruby/lib/recurly/resource/pager.rb:171:in `load!' ./recurly-client-ruby/lib/recurly/resource/pager.rb:136:in `each' ./recurly-client-ruby/spec/recurly/add_on_spec.rb:78:in `first' ./recurly-client-ruby/spec/recurly/add_on_spec.rb:78:in `block (3 levels) in ' Fixing the format makes all tests green when running with `XML=nokogiri`. --- spec/fixtures/plans/add_ons/index-200-tiered-percentage.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/fixtures/plans/add_ons/index-200-tiered-percentage.xml b/spec/fixtures/plans/add_ons/index-200-tiered-percentage.xml index 009344849..f69e2efe7 100644 --- a/spec/fixtures/plans/add_ons/index-200-tiered-percentage.xml +++ b/spec/fixtures/plans/add_ons/index-200-tiered-percentage.xml @@ -1,7 +1,7 @@ HTTP/1.1 200 OK - Content-Type: application/xml; charset=utf-8 +Content-Type: application/xml; charset=utf-8 - + From 28ca8069fe1bc08387cf2656aac0af7c072780dc Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 12 May 2022 11:39:34 -0300 Subject: [PATCH 2/2] Fix Nokogiri warning by passing the document as argument This warning is triggered in multiple specs when running with `XML=nokogiri`: ./recurly-client-ruby/lib/recurly/xml/nokogiri.rb:11: warning: Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri. By changing to passing the document instead, as per the warning message, all tests are green and no warning is issued anymore. --- lib/recurly/xml/nokogiri.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/recurly/xml/nokogiri.rb b/lib/recurly/xml/nokogiri.rb index 2b04f2005..41d3cb364 100644 --- a/lib/recurly/xml/nokogiri.rb +++ b/lib/recurly/xml/nokogiri.rb @@ -8,7 +8,7 @@ def initialize xml end def add_element name, value = nil - root.add_child(node = ::Nokogiri::XML::Element.new(name, root)) + root.add_child(node = ::Nokogiri::XML::Element.new(name, root.document)) node << value if value node end