|
3 | 3 | describe String do |
4 | 4 | describe '#sanitize_for_print' do |
5 | 5 | subject { %Q[this is\na "new line"] } |
| 6 | + |
6 | 7 | it "escapes newlines and quotes" do |
7 | 8 | expect(subject.sanitize_for_print).to eq "this is\\na \\\"new line\\\"" |
8 | 9 | end |
9 | 10 | end |
10 | 11 |
|
11 | 12 | describe '#indent' do |
12 | 13 | subject { "hello" } |
| 14 | + |
13 | 15 | it "prepends the string with spaces" do |
14 | 16 | expect(subject.indent 3).to eq " hello" |
15 | 17 | end |
| 18 | + |
| 19 | + context "when offset is 0" do |
| 20 | + it "returns the string as is" do |
| 21 | + expect(subject.indent 0).to eq subject |
| 22 | + end |
| 23 | + end |
16 | 24 | end |
17 | 25 |
|
18 | 26 | describe '#wrap' do |
19 | 27 | subject { "a long line of text that is going to be wrapped, fingers crossed!" } |
| 28 | + |
20 | 29 | it "wraps the string to the specified length" do |
21 | 30 | expect(subject.wrap 30).to eq "a long line of text that is\ngoing to be wrapped, fingers\ncrossed!" |
22 | 31 | end |
23 | 32 |
|
24 | 33 | # GH-79 |
25 | 34 | context "with an uninterrupted string" do |
26 | 35 | subject { "a long line of text with a nice uninterrupted-string-like-a-url-for-example" } |
| 36 | + |
27 | 37 | it "does not break the uninterrupted portion" do |
28 | 38 | expect(subject.wrap 30).to eq "a long line of text with a\nnice\nuninterrupted-string-like-a-url-for-example" |
29 | 39 | end |
|
84 | 94 |
|
85 | 95 | context "with a string that contains front matter" do |
86 | 96 | subject { "#{front_matter}\n---\n#{rest}" } |
| 97 | + |
87 | 98 | let(:front_matter) { "this is the front matter" } |
88 | 99 | let(:rest) { "this is\nthe script" } |
89 | 100 |
|
|
94 | 105 |
|
95 | 106 | context "with a string that contains front matter with a leading separator" do |
96 | 107 | subject { "---\n#{front_matter}\n---\n#{rest}" } |
| 108 | + |
97 | 109 | let(:front_matter) { "this is the front matter" } |
98 | 110 | let(:rest) { "this is\nthe script" } |
99 | 111 |
|
|
0 commit comments