2015-02-08 18:01:31 -05:00
|
|
|
|
# coding: utf-8
|
2014-07-08 11:15:23 -04:00
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2015-12-09 05:55:36 -05:00
|
|
|
|
describe Gitlab::Regex, lib: true do
|
2015-03-24 11:58:44 -04:00
|
|
|
|
describe 'project path regex' do
|
|
|
|
|
it { expect('gitlab-ce').to match(Gitlab::Regex.project_path_regex) }
|
|
|
|
|
it { expect('gitlab_git').to match(Gitlab::Regex.project_path_regex) }
|
|
|
|
|
it { expect('_underscore.js').to match(Gitlab::Regex.project_path_regex) }
|
|
|
|
|
it { expect('100px.com').to match(Gitlab::Regex.project_path_regex) }
|
|
|
|
|
it { expect('?gitlab').not_to match(Gitlab::Regex.project_path_regex) }
|
|
|
|
|
it { expect('git lab').not_to match(Gitlab::Regex.project_path_regex) }
|
|
|
|
|
it { expect('gitlab.git').not_to match(Gitlab::Regex.project_path_regex) }
|
2014-07-08 11:15:23 -04:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'project name regex' do
|
2015-02-12 13:17:35 -05:00
|
|
|
|
it { expect('gitlab-ce').to match(Gitlab::Regex.project_name_regex) }
|
|
|
|
|
it { expect('GitLab CE').to match(Gitlab::Regex.project_name_regex) }
|
|
|
|
|
it { expect('100 lines').to match(Gitlab::Regex.project_name_regex) }
|
|
|
|
|
it { expect('gitlab.git').to match(Gitlab::Regex.project_name_regex) }
|
2015-02-08 18:01:31 -05:00
|
|
|
|
it { expect('Český název').to match(Gitlab::Regex.project_name_regex) }
|
|
|
|
|
it { expect('Dash – is this').to match(Gitlab::Regex.project_name_regex) }
|
2015-02-12 13:17:35 -05:00
|
|
|
|
it { expect('?gitlab').not_to match(Gitlab::Regex.project_name_regex) }
|
2014-07-08 11:15:23 -04:00
|
|
|
|
end
|
2016-02-01 10:20:49 -05:00
|
|
|
|
|
|
|
|
|
describe 'file name regex' do
|
|
|
|
|
it { expect('foo@bar').to match(Gitlab::Regex.file_name_regex) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'file path regex' do
|
|
|
|
|
it { expect('foo@/bar').to match(Gitlab::Regex.file_path_regex) }
|
|
|
|
|
end
|
2016-12-07 20:09:18 -05:00
|
|
|
|
|
|
|
|
|
describe 'environment slug regex' do
|
|
|
|
|
def be_matched
|
|
|
|
|
match(Gitlab::Regex.environment_slug_regex)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it { expect('foo').to be_matched }
|
|
|
|
|
it { expect('foo-1').to be_matched }
|
|
|
|
|
|
|
|
|
|
it { expect('FOO').not_to be_matched }
|
|
|
|
|
it { expect('foo/1').not_to be_matched }
|
|
|
|
|
it { expect('foo.1').not_to be_matched }
|
|
|
|
|
it { expect('foo*1').not_to be_matched }
|
|
|
|
|
it { expect('9foo').not_to be_matched }
|
|
|
|
|
it { expect('foo-').not_to be_matched }
|
|
|
|
|
end
|
2014-07-08 11:15:23 -04:00
|
|
|
|
end
|