debian-mirror-gitlab/spec/lib/gitlab/regex_spec.rb

67 lines
2.2 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
# coding: utf-8
2014-09-02 18:07:02 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Gitlab::Regex do
2017-08-17 22:00:37 +05:30
describe '.project_name_regex' do
subject { described_class.project_name_regex }
it { is_expected.to match('gitlab-ce') }
it { is_expected.to match('GitLab CE') }
it { is_expected.to match('100 lines') }
it { is_expected.to match('gitlab.git') }
it { is_expected.to match('Český název') }
it { is_expected.to match('Dash is this') }
it { is_expected.not_to match('?gitlab') }
end
2018-03-17 18:26:18 +05:30
describe '.environment_name_regex' do
2017-09-10 17:25:29 +05:30
subject { described_class.environment_name_regex }
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
it { is_expected.to match('foo') }
2018-03-27 19:54:05 +05:30
it { is_expected.to match('a') }
2017-09-10 17:25:29 +05:30
it { is_expected.to match('foo-1') }
it { is_expected.to match('FOO') }
it { is_expected.to match('foo/1') }
it { is_expected.to match('foo.1') }
it { is_expected.not_to match('9&foo') }
it { is_expected.not_to match('foo-^') }
2018-03-17 18:26:18 +05:30
it { is_expected.not_to match('!!()()') }
2018-03-27 19:54:05 +05:30
it { is_expected.not_to match('/foo') }
it { is_expected.not_to match('foo/') }
it { is_expected.not_to match('/foo/') }
it { is_expected.not_to match('/') }
2017-08-17 22:00:37 +05:30
end
2019-10-12 21:52:04 +05:30
describe '.environment_scope_regex' do
subject { described_class.environment_scope_regex }
it { is_expected.to match('foo') }
it { is_expected.to match('foo*Z') }
it { is_expected.not_to match('!!()()') }
end
2017-08-17 22:00:37 +05:30
describe '.environment_slug_regex' do
subject { described_class.environment_slug_regex }
it { is_expected.to match('foo') }
it { is_expected.to match('foo-1') }
it { is_expected.not_to match('FOO') }
it { is_expected.not_to match('foo/1') }
it { is_expected.not_to match('foo.1') }
it { is_expected.not_to match('foo*1') }
it { is_expected.not_to match('9foo') }
it { is_expected.not_to match('foo-') }
end
2017-09-10 17:25:29 +05:30
describe '.container_repository_name_regex' do
subject { described_class.container_repository_name_regex }
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
it { is_expected.to match('image') }
it { is_expected.to match('my/image') }
it { is_expected.to match('my/awesome/image-1') }
it { is_expected.to match('my/awesome/image.test') }
it { is_expected.not_to match('.my/image') }
it { is_expected.not_to match('my/image.') }
2016-04-02 18:10:28 +05:30
end
2014-09-02 18:07:02 +05:30
end