From 3169a43f4c24d01c64c90ab9537da284f587c726 Mon Sep 17 00:00:00 2001 From: Maksym Melnychok Date: Mon, 8 Feb 2016 07:50:35 -0800 Subject: Add dig() function Deprecates #try_get_value() --- spec/functions/dig_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spec/functions/dig_spec.rb (limited to 'spec/functions/dig_spec.rb') diff --git a/spec/functions/dig_spec.rb b/spec/functions/dig_spec.rb new file mode 100644 index 0000000..1c5d49d --- /dev/null +++ b/spec/functions/dig_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe 'dig' do + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params('bad', []).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params({}, 'bad').and_raise_error(Puppet::ParseError) } + + it { is_expected.to run.with_params({}, []).and_return({}) } + it { is_expected.to run.with_params({"a" => "b"}, ["a"]).and_return("b") } + it { is_expected.to run.with_params({"a" => {"b" => "c"}}, ["a", "b"]).and_return("c") } + it { is_expected.to run.with_params({}, ["a", "b"], "d").and_return("d") } + it { is_expected.to run.with_params({"a" => false}, ["a"]).and_return(false) } +end -- cgit v1.2.3