sconover / wrong

Wrong provides a general assert method that takes a predicate block. Assertion failure messages are rich in detail.
MIT License
434 stars 31 forks source link

Add short-circuit return in Wrong::FailureMessage::wrap_and_indent, t… #47

Open jonswar opened 9 years ago

jonswar commented 9 years ago

Add short-circuit return in Wrong::FailureMessage::wrap_and_indent, to prevent infinite loop in environments where the width of Wrong::Terminal.size is incorrectly set to 0 (or <=6).

The infinite loop can be reproduced with:

#!/usr/bin/env ruby
require 'wrong/assert'
include Wrong::Assert
ENV['COLUMNS'] = '6'
f = "aaaaa"
assert { f.nil? }

Yes, most terminal widths shouldn't be set to 0, but in my case a combination of iterm + emacs caused it to be so.

kaorukobo commented 4 years ago

Thank you for the great library and jonswar's helpful patch. On my RubyMine's runner, it caused the same infinite loop and jonswar's patch solved the problem. I hope this PR will be accepted and the gem will be bumped to 0.7.2.