summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
index 0da04d8dcf7..83742699d3d 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
@@ -1,9 +1,13 @@
# frozen_string_literal: true
require 'fast_spec_helper'
+require 'support/helpers/stubbed_feature'
+require 'support/helpers/stub_feature_flags'
require_dependency 're2'
RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::Matches do
+ include StubFeatureFlags
+
let(:left) { double('left') }
let(:right) { double('right') }
@@ -148,5 +152,29 @@ RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexeme::Matches do
it { is_expected.to eq(false) }
end
+
+ context 'when right value is a regexp string' do
+ let(:right_value) { '/^ab.*/' }
+
+ context 'when matching' do
+ let(:left_value) { 'abcde' }
+
+ it { is_expected.to eq(true) }
+
+ context 'when the FF ci_fix_rules_if_comparison_with_regexp_variable is disabled' do
+ before do
+ stub_feature_flags(ci_fix_rules_if_comparison_with_regexp_variable: false)
+ end
+
+ it { is_expected.to eq(false) }
+ end
+ end
+
+ context 'when not matching' do
+ let(:left_value) { 'dfg' }
+
+ it { is_expected.to eq(false) }
+ end
+ end
end
end