diff --git a/lib/shoulda/matchers/util/word_wrap.rb b/lib/shoulda/matchers/util/word_wrap.rb index 85cda122..9779d0e4 100644 --- a/lib/shoulda/matchers/util/word_wrap.rb +++ b/lib/shoulda/matchers/util/word_wrap.rb @@ -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 diff --git a/spec/unit/shoulda/matchers/util/word_wrap_spec.rb b/spec/unit/shoulda/matchers/util/word_wrap_spec.rb index 6b80a069..0babbef4 100644 --- a/spec/unit/shoulda/matchers/util/word_wrap_spec.rb +++ b/spec/unit/shoulda/matchers/util/word_wrap_spec.rb @@ -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,