diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 067935c82a6a86fadb7170967df5730065ab790f..2c4b68c10b688402ec76dc2e63ff43c1ca827c62 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -203,14 +203,12 @@ describe API::API, api: true  do
       json_response['message']['name'].should == [
         'can\'t be blank',
         'is too short (minimum is 0 characters)',
-        'can contain only letters, digits, \'_\', \'-\' and \'.\' and '\
-        'space. It must start with letter, digit or \'_\'.'
+        Gitlab::Regex.project_regex_message
       ]
       json_response['message']['path'].should == [
         'can\'t be blank',
         'is too short (minimum is 0 characters)',
-        'can contain only letters, digits, \'_\', \'-\' and \'.\'. ' \
-        'Cannot start with \'-\' or end in \'.git\''
+        Gitlab::Regex.send(:default_regex_message)
       ]
     end
 
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index a1a26d80a149e1786eb993fa178780fbe5f923f1..113a39b870ed9e5e85d293a51458ef1426650a5f 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -140,8 +140,7 @@ describe API::API, api: true  do
       json_response['message']['projects_limit'].
           should == ['must be greater than or equal to 0']
       json_response['message']['username'].
-          should == ['can contain only letters, digits, '\
-          '\'_\', \'-\' and \'.\'. Cannot start with \'-\' or end in \'.git\'']
+          should == [Gitlab::Regex.send(:default_regex_message)]
     end
 
     it "shouldn't available for non admin users" do
@@ -283,8 +282,7 @@ describe API::API, api: true  do
       json_response['message']['projects_limit'].
           should == ['must be greater than or equal to 0']
       json_response['message']['username'].
-          should == ['can contain only letters, digits, '\
-          '\'_\', \'-\' and \'.\'. Cannot start with \'-\' or end in \'.git\'']
+          should == [Gitlab::Regex.send(:default_regex_message)]
     end
 
     context "with existing user" do