puppet-neutron/spec/functions/convert_to_json_string_spec.rb
Tobias Urdin 37bb654424 Use puppet4 functions-api
Change-Id: Id124ec4c598c7b6bcb7c8134d75825fd01d938d2
2018-12-18 10:32:11 +00:00

23 lines
592 B
Ruby

require 'spec_helper'
describe 'convert_to_json_string' do
it 'exists' do
is_expected.not_to eq(nil)
end
it 'hash to json string' do
data = {:some => "data"}
is_expected.to run.with_params(data).and_return('{"some":"data"}')
end
it 'array of strings with kv to json string' do
data = ['mykey:myvalue', 'key2:val2']
is_expected.to run.with_params(data).and_return('{"mykey":"myvalue","key2":"val2"}')
end
it 'array of strings to json strings' do
data = ['val1', 'val2']
is_expected.to run.with_params(data).and_return('["val1","val2"]')
end
end