require "spec_helper" require "nokogiri" describe ParagraphMaker do include ParagraphMaker describe "process" do it "converts single linebreaks to br and wrap with p" do result = process(Nokogiri::HTML5.fragment("some\ntext")) expect(result.to_html).to eq("

some
\ntext

") end it "converts double linebreaks to paragraph break and keep separate lines" do result = process(Nokogiri::HTML5.fragment("some\n\ntext")) expect(result.to_html).to eq("

some

\n

text

") end it "converts five linebreaks to blank paragraph and keep separate lines" do result = process(Nokogiri::HTML5.fragment("a paragraph\n\n\n\n\nanother paragraph")) expect(result.to_html).to eq(<<~HTML.strip)

a paragraph

 

another paragraph

HTML end end end