diff options
author | Maksym Melnychok <maksym@yelp.com> | 2016-02-08 07:50:35 -0800 |
---|---|---|
committer | Maksym Melnychok <maksym@yelp.com> | 2016-02-16 00:51:28 -0800 |
commit | 3169a43f4c24d01c64c90ab9537da284f587c726 (patch) | |
tree | 8ce7f17067cb5df0e75784f400d3ccc1c7c6f505 /spec/functions | |
parent | 990e1d757549a9c792cf5f7113e4d6bcd592ae3d (diff) |
Add dig() function
Deprecates #try_get_value()
Diffstat (limited to 'spec/functions')
-rw-r--r-- | spec/functions/dig_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
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 |