Skip to content
Snippets Groups Projects
Commit 6eeb837f authored by Grzegorz Bizon's avatar Grzegorz Bizon :bulb:
Browse files

Merge branch 'feature/gb/pipeline-variable-expressions' into...

Merge branch 'feature/gb/pipeline-variable-expressions' into feature/gb/variables-expressions-in-only-except

* feature/gb/pipeline-variable-expressions:
  Do not use keyword args to pass expression variables
parents c5225588 886988c9
No related branches found
No related tags found
1 merge request!17316Pipeline variables expression in only/except configuration
......@@ -11,7 +11,7 @@ def initialize(left, right)
@right = right
end
def evaluate(**variables)
def evaluate(variables = {})
@left.evaluate(variables) == @right.evaluate(variables)
end
......
......@@ -10,7 +10,7 @@ def initialize(value = nil)
@value = nil
end
def evaluate(**_)
def evaluate(variables = {})
nil
end
......
......@@ -10,7 +10,7 @@ def initialize(value)
@value = value
end
def evaluate(**_)
def evaluate(variables = {})
@value.to_s
end
......
......@@ -10,8 +10,8 @@ def initialize(name)
@name = name
end
def evaluate(**variables)
variables[@name.to_sym]
def evaluate(variables = {})
HashWithIndifferentAccess.new(variables).fetch(@name, nil)
end
def self.build(string)
......
......@@ -20,7 +20,7 @@ def initialize(statement, pipeline = nil)
return if pipeline.nil?
@variables = pipeline.variables.map do |variable|
[variable.key.to_sym, variable.value]
[variable.key, variable.value]
end
end
......
......@@ -22,6 +22,13 @@
.to eq 'my variable'
end
it 'allows to use a string as a variable key too' do
variable = described_class.new('VARIABLE')
expect(variable.evaluate('VARIABLE' => 'my variable'))
.to eq 'my variable'
end
it 'returns nil if it is not defined' do
variable = described_class.new('VARIABLE')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment