spec/support/random.rb in imw-0.2.10 vs spec/support/random.rb in imw-0.2.11

- 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.rand }.join + filename = (1..length).map { |i| FILENAME_CHARS.choice }.join # filenames beginning with hyphens suck while (filename[0,1] == '-') do - filename[0] = FILENAME_CHARS.rand + filename[0] = FILENAME_CHARS.choice 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.rand }.join + (1..length).map { |i| char_pool.choice }.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].rand + ext = options[:extensions].choice name = self.basename if ext == 'dir' then if depth <= options[:max_depth] then newd = directory + '/' + name FileUtils.mkdir(newd)