forked from refinery/refinerycms
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require truncate_html only in helper because that's currently the onl…
…y place where it's used. Add specs for Refinery::HtmlTruncationHelper.
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require "spec_helper" | ||
|
||
module Refinery | ||
describe HtmlTruncationHelper do | ||
|
||
it "returns nil if text is not present" do | ||
helper.truncate("").should be_nil | ||
end | ||
|
||
context "when preserve_html_tags option is present" do | ||
it "preserve html tags when truncating text" do | ||
helper.truncate("<p>Turducken frankfurter ham hock bacon</p>", | ||
:preserve_html_tags => true).should eq("<p>Turducken frankfurter ham...</p>") | ||
end | ||
end | ||
|
||
context "when preserve_html_tags option is not present" do | ||
it "falls back to original truncate method" do | ||
helper.truncate("<p>Turducken frankfurter ham hock bacon</p>").should eq("<p>Turducken frankfurter ha...") | ||
end | ||
end | ||
|
||
end | ||
end |