From 2e5eee1300b7ae52b5eac5f17e27df27f2620564 Mon Sep 17 00:00:00 2001 From: mishina <32959831+mishina2228@users.noreply.github.com> Date: Mon, 2 May 2022 01:56:22 +0900 Subject: [PATCH] Fix deprecation warnings (#417) * Fix Nokogiri deprecation warning Nokogiri warning: ``` 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. ``` Please see the following for more details: https://github.com/sparklemotion/nokogiri/issues/975 * Require 'mocha/test_unit' instead of 'mocha/setup' Suppress the following deprecation warning: ``` Mocha deprecation warning at /home/runner/work/gollum-lib/gollum-lib/test/helper.rb:9:in `require': Require 'mocha/test_unit', 'mocha/minitest' or 'mocha/api' instead of 'mocha/setup'. ``` --- lib/gollum-lib/filter/toc.rb | 8 ++++---- test/helper.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/gollum-lib/filter/toc.rb b/lib/gollum-lib/filter/toc.rb index 5431ce4f..1fe08946 100644 --- a/lib/gollum-lib/filter/toc.rb +++ b/lib/gollum-lib/filter/toc.rb @@ -125,7 +125,7 @@ def generate_anchor_name(header) # Creates an anchor element with the given name and adds it before # the given header element. def add_anchor_to_header(header, name) - a = Nokogiri::XML::Node.new('a', @doc) + a = Nokogiri::XML::Node.new('a', @doc.document) a['class'] = 'anchor' a['id'] = name a['href'] = "##{name}" @@ -143,9 +143,9 @@ def add_entry_to_toc(header, name) if @tail_level < level while @tail_level < level - list = Nokogiri::XML::Node.new('ul', @doc) + list = Nokogiri::XML::Node.new('ul', @doc.document) @tail.add_child(list) - @tail = list.add_child(Nokogiri::XML::Node.new('li', @doc)) + @tail = list.add_child(Nokogiri::XML::Node.new('li', @doc.document)) @tail_level += 1 end else @@ -153,7 +153,7 @@ def add_entry_to_toc(header, name) @tail = @tail.parent.parent @tail_level -= 1 end - @tail = @tail.parent.add_child(Nokogiri::XML::Node.new('li', @doc)) + @tail = @tail.parent.add_child(Nokogiri::XML::Node.new('li', @doc.document)) end # % -> %25 so anchors work on Firefox. See issue #475 diff --git a/test/helper.rb b/test/helper.rb index 70bb3be0..cb11ecb3 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -6,7 +6,7 @@ # external require 'rubygems' require 'shoulda' -require 'mocha/setup' +require 'mocha/test_unit' require 'minitest/reporters' require 'twitter_cldr' require 'tempfile'