Quick tip - Generating long strings for testing

Updated based on Sergey’s comment

Next time you need to create long strings to test validations like this:

validates_length_of :details, :maximum => 4000

try this

# the wrong way
returning(''){|s| 4001.times{|t| s << t.to_s } }

# the right way (thanks Sergey)

Anyone have a better way?

Comment or question via
FYI: This post was migrated over from another blogging engine. If you encounter any issues please let me know on . Thanks.