1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Fix word_wrap not to break at max line length

...but *after* the max line length.
This commit is contained in:
Elliot Winkler 2015-11-27 19:25:47 -07:00
parent 8e68d99217
commit a0b6cb2581
2 changed files with 12 additions and 1 deletions

View file

@ -165,7 +165,7 @@ module Shoulda
end
def determine_where_to_break_line(line)
index = TERMINAL_WIDTH - 1
index = TERMINAL_WIDTH
while line[index] !~ /\s/
index -= 1

View file

@ -35,6 +35,17 @@ luscious, ipsum sit amet efficitur feugiat
MESSAGE
end
it "does not break at the maximum line length, but afterward" do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luscius, ipsum sit amet efficitur feugiat
MESSAGE
expect(wrapped_message).to eq(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luscius,
ipsum sit amet efficitur feugiat
MESSAGE
end
it "re-wraps entire paragraphs" do
wrapped_message = described_class.word_wrap(<<-MESSAGE)
Lorem ipsum dolor sit amet,