Skip to content

Commit

Permalink
ensure return value of Mapping#extensions_for is unique
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux authored and judofyr committed Aug 4, 2022
1 parent 686cafa commit deba57e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tilt/mapping.rb
Expand Up @@ -188,7 +188,7 @@ def extensions_for(template_class)
lazy_map.each do |ext, choices|
res << ext if choices.any? { |klass, file| template_class.to_s == klass }
end
res
res.uniq
end

private
Expand Down
7 changes: 7 additions & 0 deletions test/tilt_asciidoctor_test.rb
Expand Up @@ -24,6 +24,13 @@ def strip_space(str)
assert_equal Tilt::AsciidoctorTemplate, Tilt['asciidoc']
end

test "#extensions_for returns a unique list of extensions" do
Tilt.default_mapping.extensions_for(Tilt::AsciidoctorTemplate).each do |ext|
Tilt[ext]
end
assert_equal ['ad', 'adoc', 'asciidoc'], Tilt.default_mapping.extensions_for(Tilt::AsciidoctorTemplate).sort
end

test "preparing and evaluating html5 templates on #render" do
template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'html5'}) { |t| "== Hello World!" }
assert_equal HTML5_OUTPUT, strip_space(template.render)
Expand Down

0 comments on commit deba57e

Please sign in to comment.