Skip to content

Commit

Permalink
Fix deprecation warnings (#417)
Browse files Browse the repository at this point in the history
* 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:
sparklemotion/nokogiri#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'.
```
  • Loading branch information
mishina2228 authored May 1, 2022
1 parent 6836467 commit 2e5eee1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/gollum-lib/filter/toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -143,17 +143,17 @@ 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
while @tail_level > level
@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
Expand Down
2 changes: 1 addition & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# external
require 'rubygems'
require 'shoulda'
require 'mocha/setup'
require 'mocha/test_unit'
require 'minitest/reporters'
require 'twitter_cldr'
require 'tempfile'
Expand Down

0 comments on commit 2e5eee1

Please sign in to comment.