Sha256: 5f5b9eb34d928a3cc5a65558c46bd928a96045ce9eacff2d09e2484d0caf8865
Contents?: true
Size: 825 Bytes
Versions: 3
Compression:
Stored size: 825 Bytes
Contents
require "test/unit/testcase" module Test module Unit module AssertionsWithDiff def assert_equal(expected, actual, message=nil) super rescue AssertionFailedError expected = PP.pp(expected, "") unless expected.is_a?(String) actual = PP.pp(actual, "") unless actual.is_a?(String) diff = Diff.readable(expected, actual) if /^[\?\-\+].{79}/ =~ diff folded_diff = Diff.readable(fold(expected), fold(actual)) diff = "#{diff}\nfolded diff:\n#{folded_diff}" end raise $!, "#{$!.message}\ndiff:\n#{diff}", $@ end def fold(string) string.split(/\n/).collect do |line| line.gsub(/(.{78})/, "\\1\n") end.join("\n") end end class TestCase include AssertionsWithDiff end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
test-unit-ext-0.2.0 | lib/test-unit-ext/assertions.rb |
test-unit-ext-0.3.0 | lib/test-unit-ext/assertions.rb |
test-unit-ext-0.4.0 | lib/test-unit-ext/assertions.rb |