Skip to content

Commit

Permalink
resolves #4270 don't raise error if Asciidoctor::Extensions.unregiste…
Browse files Browse the repository at this point in the history
…r is called before groups are initialized
  • Loading branch information
mojavelinux committed Apr 4, 2022
1 parent 8e573ac commit 0ba8980
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Expand Up @@ -19,6 +19,7 @@ This project utilizes semantic versioning.

Bug Fixes::

* Don't raise error if `Asciidoctor::Extensions.unregister` is called before groups are initialized (#4270)
* If path is included both partially and fully, store it with true value (included fully) in includes table of document catalog
* Reset registry if activate is called on it again (#4256)
* Format source location in exception message when extension code is malformed
Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/extensions.rb
Expand Up @@ -1540,7 +1540,7 @@ def unregister_all
#
# Returns nothing
def unregister *names
names.each {|group| @groups.delete group.to_sym }
names.each_with_object(groups) {|group, catalog| catalog.delete group.to_sym }
nil
end
end
Expand Down
13 changes: 13 additions & 0 deletions test/extensions_test.rb
Expand Up @@ -344,6 +344,19 @@ def create_santa_list_block_macro
end
end

test 'should not fail to unregister extension group if not registered' do
refute_nil Asciidoctor::Extensions.groups
assert_equal 0, Asciidoctor::Extensions.groups.size
Asciidoctor::Extensions.unregister :sample
assert_equal 0, Asciidoctor::Extensions.groups.size
end

test 'should not fail to unregister extension group if extension groups are not initialized' do
Asciidoctor::Extensions.remove_instance_variable :@groups
Asciidoctor::Extensions.unregister :sample
assert_equal 0, Asciidoctor::Extensions.groups.size
end

test 'should raise NameError if extension class cannot be resolved from string' do
begin
Asciidoctor::Extensions.register do
Expand Down

0 comments on commit 0ba8980

Please sign in to comment.