Skip to content

Commit 42c2225

Browse files
committed
don't modify the input string in place
1 parent 94d27e1 commit 42c2225

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/email_reply_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def initialize
6262
def read(text)
6363
# The text is reversed initially due to the way we check for hidden
6464
# fragments.
65-
text.reverse!
65+
text = text.reverse
6666

6767
# This determines if any 'visible' Fragment has been found. Once any
6868
# visible Fragment is found, stop looking for hidden ones.

test/email_reply_parser_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ def test_recognizes_date_string_above_quote
7171
assert_match /Loader/, reply.fragments[1].to_s
7272
end
7373

74+
def test_does_not_modify_input_string
75+
original = "The Quick Brown Fox Jumps Over The Lazy Dog"
76+
EmailReplyParser.read original
77+
assert_equal "The Quick Brown Fox Jumps Over The Lazy Dog", original
78+
end
79+
7480
def email(name)
7581
body = IO.read EMAIL_FIXTURE_PATH.join("#{name}.txt").to_s
7682
EmailReplyParser.read body

0 commit comments

Comments
 (0)