Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing additions on the Excerpt class #1893

Merged
merged 3 commits into from
Dec 30, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions test/test_excerpt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,48 @@ def do_render(post)
@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_equal @excerpt.id, "#{@post.id}/#excerpt"
end
should "return a string" do
assert_same @post.id.class, String
end
end

context "#to_s" do
should "return its content if no output present" do
assert_equal @excerpt.content, @excerpt.to_s
end

should "return its output if output present" do
@excerpt.output = "Fake Output"
assert_equal @excerpt.output, @excerpt.to_s
end
end

context "#inspect" do
should "contain the excerpt id as a shorthand string identifier" do
assert_equal @excerpt.inspect, "<Excerpt: #{@excerpt.id}>"
end

should "return a string" do
assert_same @post.id.class, String
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"]
Expand Down