Permalink
Browse files

Added GithubUsername regex

  • Loading branch information...
jaimeiniesta authored and eparreno committed May 17, 2010
1 parent e7f2aeb commit 3bf1a96e397d6e06540334952dc3ac819ba553d2
Showing with 20 additions and 0 deletions.
  1. +3 −0 lib/ruby_regex.rb
  2. +17 −0 test/ruby_regex_test.rb
View
@@ -63,4 +63,7 @@ module RubyRegex
# Twitter username
TwitterUsername = /^([a-z0-9\_])+$/ix
+
+ # Github username
+ GithubUsername = /^([a-z0-9\_\-])+$/ix
end
View
@@ -177,4 +177,21 @@ def test_invalid_twitter_usernames
assert(twitter_username !~ RubyRegex::TwitterUsername, message)
end
end
+
+ # Github usernames
+ def test_valid_github_usernames
+ github_usernames = ['ji', 'nickel84', 'sepa_rate', 'ernesto-jimenez']
+ github_usernames.each do |github_username|
+ message = build_message(message, '<?> does not pass the test', github_username)
+ assert(github_username =~ RubyRegex::GithubUsername, message)
+ end
+ end
+
+ def test_invalid_github_usernames
+ github_usernames = ['nickel 84', 'h.ppywebcoder']
+ github_usernames.each do |github_username|
+ message = build_message(message, '<?> does not pass the test', github_username)
+ assert(github_username !~ RubyRegex::GithubUsername, message)
+ end
+ end
end

0 comments on commit 3bf1a96

Please sign in to comment.