Class: String
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#diff(other) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/expectations/string.rb', line 2 def diff(other) (0..self.size).inject("") do |result, index| if self[index, 1] == other[index, 1] result += self[index, 1] else result += "[#{self[index, 1]}|#{other[index, 1]}], mismatch at index #{index}\n" result += "trailing expected: <#{self[index+1, self.size - index]}>\n" result += "trailing actual: <#{other[index+1, other.size - index]}>" return result end result end end |