Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/build/rules/rule/clause_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/build/rules/rule/clause_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/build/rules/rule/clause_spec.rb b/spec/lib/gitlab/ci/build/rules/rule/clause_spec.rb
new file mode 100644
index 00000000000..faede7a361f
--- /dev/null
+++ b/spec/lib/gitlab/ci/build/rules/rule/clause_spec.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Ci::Build::Rules::Rule::Clause do
+ describe '.fabricate' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:value) { 'some value' }
+
+ subject { described_class.fabricate(type, value) }
+
+ context 'when type is valid' do
+ where(:type, :result) do
+ 'changes' | Gitlab::Ci::Build::Rules::Rule::Clause::Changes
+ 'exists' | Gitlab::Ci::Build::Rules::Rule::Clause::Exists
+ 'if' | Gitlab::Ci::Build::Rules::Rule::Clause::If
+ end
+
+ with_them do
+ it { is_expected.to be_instance_of(result) }
+ end
+ end
+
+ context 'when type is invalid' do
+ let(:type) { 'when' }
+
+ it { is_expected.to be_nil }
+
+ context "when type is 'variables'" do
+ let(:type) { 'variables' }
+
+ it { is_expected.to be_nil }
+ end
+ end
+ end
+end