test/generator_test.rb in namna-0.0.3 vs test/generator_test.rb in namna-0.0.4

- old
+ new

@@ -1,20 +1,26 @@ require_relative './test_helper' class TestGenerator < Minitest::Test - def setup - @generator = Generator.new('a?*#z') + def test_random + assert (3..7).include?(Generator.random.length) + assert_equal 5, Generator.random(5).length end - def test_initialize - assert_equal 5, @generator.format.length + def test_human + assert (3..7).include?(Generator.human.length) + assert_equal 5, Generator.human(5).length end - def test_generate - assert_equal 5, @generator.generate.length - assert_equal 'a', @generator.generate[0] - assert_includes String::ALPHABET, @generator.generate[1] - assert_includes String::VOWELS, @generator.generate[2] - assert_includes String::CONSONANTS, @generator.generate[3] - assert_equal 'z', @generator.generate[4] + def test_format + name = Generator.format('a?*#z') + + assert_equal 5, name.length + + assert_equal 'a', name[0] + assert_equal 'z', name[4] + + assert_includes String::ALPHABET, name[1] + assert_includes String::VOWELS, name[2] + assert_includes String::CONSONANTS, name[3] end end