Testing ExcerptDrop Data Inheritance Implementation in Jekyll
This test suite validates the ExcerptDrop functionality in Jekyll, focusing on document excerpt handling and liquid drop behavior. It ensures proper inheritance and data handling between documents and their excerpts.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
jekyll/jekyll
test/test_excerpt_drop.rb
# frozen_string_literal: true
require "helper"
class TestExcerptDrop < JekyllUnitTest
context "an excerpt drop" do
setup do
@site = fixture_site
@site.read
@doc = @site.docs_to_write.find { |d| !d.data["layout"].nil? }
@doc_drop = @doc.to_liquid
@excerpt = @doc.data["excerpt"]
@excerpt_drop = @excerpt.to_liquid
end
should "have the right thing" do
assert_kind_of Jekyll::Document, @doc
assert_kind_of Jekyll::Drops::DocumentDrop, @doc_drop
assert_kind_of Jekyll::Excerpt, @excerpt
assert_kind_of Jekyll::Drops::ExcerptDrop, @excerpt_drop
end
should "not have an excerpt" do
assert_nil @excerpt.data["excerpt"]
assert @excerpt_drop.class.invokable? "excerpt"
assert_nil @excerpt_drop["excerpt"]
end
should "inherit the layout for the drop but not the excerpt" do
assert_nil @excerpt.data["layout"]
assert_equal @doc_drop["layout"], @excerpt_drop["layout"]
end
should "be inspectable" do
refute_empty @excerpt_drop.inspect
end
should "inherit values from the document" do
assert_equal @doc_drop.keys.sort, @excerpt_drop.keys.sort
end
end
end