Do not strip leading and trailing whitespace from raw posts.

This commit is contained in:
Jeremy Banks
2013-02-15 20:58:33 -05:00
parent 9cd13880ec
commit 6af69f7e77
4 changed files with 46 additions and 17 deletions

View File

@@ -38,10 +38,6 @@ describe TextSentinel do
context "cleaning up" do
it "strips leading or trailing whitespace" do
TextSentinel.new(" \t test \t ").text.should == "test"
end
it "allows utf-8 chars" do
TextSentinel.new("йȝîûηыეமிᚉ⠛").text.should == "йȝîûηыეமிᚉ⠛"
end
@@ -49,15 +45,37 @@ describe TextSentinel do
context "interior spaces" do
let(:spacey_string) { "hello there's weird spaces here." }
let(:unspacey_string) { "hello there's weird spaces here." }
it "ignores intra spaces by default" do
TextSentinel.new(spacey_string).text.should == spacey_string
end
it "fixes intra spaces when enabled" do
TextSentinel.new(spacey_string, remove_interior_spaces: true).text.should == "hello there's weird spaces here."
end
TextSentinel.new(spacey_string, remove_interior_spaces: true).text.should == unspacey_string
end
it "fixes intra spaces in titles" do
TextSentinel.title_sentinel(spacey_string).text.should == unspacey_string
end
end
context "stripping whitespace" do
let(:spacey_string) { " \t test \t " }
let(:unspacey_string) { "test" }
it "does not strip leading and trailing whitespace by default" do
TextSentinel.new(spacey_string).text.should == spacey_string
end
it "strips leading and trailing whitespace when enabled" do
TextSentinel.new(spacey_string, strip: true).text.should == unspacey_string
end
it "strips leading and trailing whitespace in titles" do
TextSentinel.title_sentinel(spacey_string).text.should == unspacey_string
end
end
end
@@ -100,4 +118,4 @@ describe TextSentinel do
end
end
end