summaryrefslogtreecommitdiff
path: root/spec/functions/dig_spec.rb
diff options
context:
space:
mode:
authorMaksym Melnychok <maksym@yelp.com>2016-02-08 07:50:35 -0800
committerMaksym Melnychok <maksym@yelp.com>2016-02-16 00:51:28 -0800
commit3169a43f4c24d01c64c90ab9537da284f587c726 (patch)
tree8ce7f17067cb5df0e75784f400d3ccc1c7c6f505 /spec/functions/dig_spec.rb
parent990e1d757549a9c792cf5f7113e4d6bcd592ae3d (diff)
Add dig() function
Deprecates #try_get_value()
Diffstat (limited to 'spec/functions/dig_spec.rb')
-rw-r--r--spec/functions/dig_spec.rb13
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