spec/support/random.rb in imw-0.2.7 vs spec/support/random.rb in imw-0.2.8
- old
+ new
@@ -22,25 +22,25 @@
] unless defined?(EXTENSIONS)
# Return a random filename. Optional +length+ to set the maximum
# length of the filename returned.
def self.basename options = {}
length = (options[:length] or FILENAME_MAX_LENGTH)
- filename = (1..length).map { |i| FILENAME_CHARS.random }.join
+ filename = (1..length).map { |i| FILENAME_CHARS.rand }.join
# filenames beginning with hyphens suck
while (filename[0,1] == '-') do
- filename[0] = FILENAME_CHARS.random
+ filename[0] = FILENAME_CHARS.rand
end
filename
end
# Return a random string of text up. Control the length with
# optional +length+ and also the presence of +newlines+.
def self.text options = {}
length = (options[:length] or TEXT_MAX_LENGTH)
char_pool = options[:newlines] ? TEXT_CHARS : STRING_CHARS
- (1..length).map { |i| char_pool.random }.join
+ (1..length).map { |i| char_pool.rand }.join
end
# Create a random file by matching the extension of the given
# +filename+ or a text file if no match is found.
def self.file filename
@@ -188,10 +188,10 @@
end
end
FileUtils.mkdir_p(directory)
(rand(options[:num_files]) + 2).times do
- ext = options[:extensions].random
+ ext = options[:extensions].rand
name = self.basename
if ext == 'dir' then
if depth <= options[:max_depth] then
newd = directory + '/' + name
FileUtils.mkdir(newd)