Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a few tests

git-svn-id: svn://rubyforge.org/var/svn/faker/trunk@16 d8fb7423-2fd9-4a2a-9c92-119baff0aaab
  • Loading branch information...
commit 338fb1c0b3a034d63dfbaebdde633c93c71b6d10 1 parent 4a643a0
bcurtis authored
Showing with 56 additions and 0 deletions.
  1. +36 −0 test/test_faker_internet.rb
  2. +20 −0 test/test_faker_name.rb
View
36 test/test_faker_internet.rb
@@ -0,0 +1,36 @@
+require File.dirname(__FILE__) + '/test_helper.rb'
+
+class TestFakerInternet < Test::Unit::TestCase
+
+ def setup
+ @tester = Faker::Internet
+ end
+
+ def test_email
+ assert @tester.email.match(/.+@.+\.\w+/)
+ end
+
+ def test_free_email
+ assert @tester.free_email.match(/.+@(gmail|hotmail|yahoo)\.com/)
+ end
+
+ def test_user_name
+ assert @tester.user_name.match(/[a-z]+((_|\.)[a-z]+)?/)
+ end
+
+ def test_user_name_with_arg
+ assert @tester.user_name('bo peep').match(/(bo(_|\.)peep|peep(_|\.)bo)/)
+ end
+
+ def test_domain_name
+ assert @tester.domain_name.match(/\w+\.\w+/)
+ end
+
+ def test_domain_word
+ assert @tester.domain_word.match(/^\w+$/)
+ end
+
+ def test_domain_suffix
+ assert @tester.domain_suffix.match(/^\w+(\.\w+)?/)
+ end
+end
View
20 test/test_faker_name.rb
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + '/test_helper.rb'
+
+class TestFakerName < Test::Unit::TestCase
+
+ def setup
+ @tester = Faker::Name
+ end
+
+ def test_name
+ assert @tester.name.match(/(\w+\.? ?){2,3}/)
+ end
+
+ def test_prefix
+ assert @tester.prefix.match(/[A-Z][a-z]+\.?/)
+ end
+
+ def test_suffix
+ assert @tester.suffix.match(/[A-Z][a-z]*\.?/)
+ end
+end

0 comments on commit 338fb1c

Please sign in to comment.
Something went wrong with that request. Please try again.