require 'spec_helper' describe ReverseAdoc::Converters::Text do let(:converter) { ReverseAdoc::Converters::Text.new } it 'treats newline within text as a single whitespace' do input = node_for("
foo\nbar
") result = converter.convert(input) expect(result).to eq 'foo bar' end it 'removes leading newlines' do input = node_for("\n\nfoo bar
") result = converter.convert(input) expect(result).to eq 'foo bar' end it 'removes trailing newlines' do input = node_for("foo bar\n\n
") result = converter.convert(input) expect(result).to eq 'foo bar' end it 'keeps nbsps' do input = node_for("foo\u00A0bar \u00A0
") result = converter.convert(input) expect(result).to eq "foo bar " end it "keeps HTML characters" do input = node_for("<foo>
") result = converter.convert(input) expect(result).to eq "<<foo>>
") result = converter.convert(input) expect(result).to eq '\<`foo_bar`
") result = converter.convert(input) expect(result).to eq '`foo_bar`' end it "preserves multiple underscores" do input = node_for("`foo_bar __example__`
") result = converter.convert(input) expect(result).to eq '`foo_bar __example__`' end it "preserves single asterisks" do input = node_for("`def foo *args`
") result = converter.convert(input) expect(result).to eq '`def foo *args`' end it "preserves multiple asterisks" do input = node_for("`def foo 2***3`
") result = converter.convert(input) expect(result).to eq '`def foo 2***3`' end end end