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

65 lines
1.8 KiB
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
require 'spec_helper'
describe ExpandVariables do
describe '#expand' do
subject { described_class.expand(value, variables) }
tests = [
{ value: 'key',
result: 'key',
2017-08-17 22:00:37 +05:30
variables: [] },
2016-09-29 09:46:39 +05:30
{ value: 'key$variable',
result: 'key',
2017-08-17 22:00:37 +05:30
variables: [] },
2016-09-29 09:46:39 +05:30
{ value: 'key$variable',
result: 'keyvalue',
variables: [
{ key: 'variable', value: 'value' }
2017-08-17 22:00:37 +05:30
] },
2016-09-29 09:46:39 +05:30
{ value: 'key${variable}',
result: 'keyvalue',
variables: [
{ key: 'variable', value: 'value' }
2017-08-17 22:00:37 +05:30
] },
2016-09-29 09:46:39 +05:30
{ value: 'key$variable$variable2',
result: 'keyvalueresult',
variables: [
{ key: 'variable', value: 'value' },
2017-09-10 17:25:29 +05:30
{ key: 'variable2', value: 'result' }
2017-08-17 22:00:37 +05:30
] },
2016-09-29 09:46:39 +05:30
{ value: 'key${variable}${variable2}',
result: 'keyvalueresult',
variables: [
{ key: 'variable', value: 'value' },
{ key: 'variable2', value: 'result' }
2017-08-17 22:00:37 +05:30
] },
2016-09-29 09:46:39 +05:30
{ value: 'key$variable2$variable',
result: 'keyresultvalue',
variables: [
{ key: 'variable', value: 'value' },
2017-09-10 17:25:29 +05:30
{ key: 'variable2', value: 'result' }
2017-08-17 22:00:37 +05:30
] },
2016-09-29 09:46:39 +05:30
{ value: 'key${variable2}${variable}',
result: 'keyresultvalue',
variables: [
{ key: 'variable', value: 'value' },
{ key: 'variable2', value: 'result' }
2017-08-17 22:00:37 +05:30
] },
{ value: 'review/$CI_COMMIT_REF_NAME',
2016-09-29 09:46:39 +05:30
result: 'review/feature/add-review-apps',
variables: [
2017-08-17 22:00:37 +05:30
{ key: 'CI_COMMIT_REF_NAME', value: 'feature/add-review-apps' }
2017-09-10 17:25:29 +05:30
] }
2016-09-29 09:46:39 +05:30
]
tests.each do |test|
context "#{test[:value]} resolves to #{test[:result]}" do
let(:value) { test[:value] }
let(:variables) { test[:variables] }
it { is_expected.to eq(test[:result]) }
end
end
end
end