rspec/rspec-support — pull request #71 by phiggins (2014-05-26 23:32:29+00:00)
Title: Don't disregard trailing newlines in Differ input. #70

A fix for #70.

`String#split` takes an optional second argument. From the docs:

> If the limit parameter is omitted, trailing null fields are suppressed. If limit is a positive number, at most that number of fields will be returned (if limit is 1, the entire string is returned as the only entry in an array). If negative, there is no limit to the number of fields returned, and trailing null fields are not suppressed.

The difference being output like this:

```
> "foo\nbar\n".split("\n")
=> ["foo", "bar"]
> "foo\nbar\n".split("\n", -1)
=> ["foo", "bar", ""]
> "foo\nbar\n\n\n".split("\n", -1)
=> ["foo", "bar", "", "", ""]
```

I modified the methods that preprocessed the input to Differ to keep these empty strings for any trailing newlines. This worked to fix the issue in #70, but I had to modify lots of Differ's test cases since they used a trailing newline to trigger their diffability.