Fix tests on 1.8 by explicitly checking for strings (which also improves performance).

This commit is contained in:
José Valim 2011-04-20 21:54:19 +02:00
parent 356dacbafc
commit d31af44012

@ -118,7 +118,15 @@ def body
def body=(body)
@blank = true if body == EMPTY
@body = body.respond_to?(:each) ? body : [body]
# Explicitly check for strings. This is *wrong* theoretically
# but if we don't check this, the performance on string bodies
# is bad on Ruby 1.8 (because strings responds to each then).
@body = if body.respond_to?(:to_str) || !body.respond_to?(:each)
[body]
else
body
end
end
def body_parts