Sha256: cb6f38ef78d8b9c15ff1955dd19ddd73977f5cd756e9816ca06f861475d83d40
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require 'rubygems' gem 'minitest' require_relative "../lib/random_strings" require "minitest/autorun" describe RandomStrings do before do @default_generator=RandomStrings::Generator.new end describe "when initializing" do it "must correctly accept a config" do @generate=(RandomStrings::Generator.new do |config| config.tld_list=['.nettld'] end) email = @generate.random_email (/.nettld$/).match(email).wont_be_nil end end describe "when getting a zip" do it "must be a five digit number" do zip=@default_generator.random_zip (/\d{5}/.match(zip)).wont_be_nil end end describe "you can get a random email" do it "must be a reasonable email" do email = @default_generator.random_email (/[a-zA-Z0-9]+\@[a-zA-Z0-9]+\.(com|org|net)/.match(email)).wont_be_nil end end describe "when generating random string" do it "has a default length of 10" do str = @default_generator.random_string str.size.must_equal 10 end it "can have a set length when initialized" do @set_gen=(RandomStrings::Generator.new do |config| config.default_string_length=42 end) str=@set_gen.random_string str.size.must_equal 42 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
random_strings-0.0.1 | test/tc_random_strings.rb |