Skip to content

Instantly share code, notes, and snippets.

@anolson
Created December 20, 2010 00:37
Show Gist options
  • Save anolson/747875 to your computer and use it in GitHub Desktop.
Save anolson/747875 to your computer and use it in GitHub Desktop.
Create random pronounceable strings
module RandomPronounceableString
VOWELS = "aeiou"
CONSONANTS = "bcdfghjklmnprstvwyz"
def random_pronounceable
%(#{random_consonant}#{random_vowel}#{random_consonant}#{random_vowel}#{random_consonant}#{random_vowel})
end
def random_vowel
random_letter(VOWELS)
end
def random_consonant
random_letter(CONSONANTS)
end
def random_letter(letters)
letters[rand(letters.length)].chr
end
end
require 'test/unit'
require 'random_pronounceable_string'
class RandomPronounceableStringTest < Test::Unit::TestCase
include RandomPronounceableString
def test_random_pronounceable
assert_not_equal random_pronounceable, random_pronounceable
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment