Adds tests for the Excerpt include?, id, and inspect methods

This commit is contained in:
Meeka 2013-12-30 12:15:13 -05:00
parent 3744e70128
commit 3a0733deb9
1 changed files with 30 additions and 0 deletions

View File

@ -35,6 +35,36 @@ class TestExcerpt < Test::Unit::TestCase
@excerpt = @post.send :extract_excerpt
end
context "#include(string)" do
setup do
@excerpt.output = "Here is a fake output stub"
end
should "return true only if an excerpt output contains a specified string" do
assert @excerpt.include?("fake output")
refute @excerpt.include?("real output")
end
end
context "#id" do
should "contain the UID for the post" do
assert_include @excerpt.id, @post.id
end
should "return a string" do
assert_same @post.id.class, String
end
end
context "#inspect" do
should "contain the excerpt id" do
assert_include @excerpt.inspect, @excerpt.id
end
should "contain the shorthand String identifier of the post" do
assert_include @excerpt.inspect, @post.slug
end
end
context "#to_liquid" do
should "contain the proper page data to mimick the post liquid" do
assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"]