summaryrefslogtreecommitdiff
path: root/spec/functions/dig_spec.rb
blob: 1c5d49d23cf98222bfc23ddc6edab9bc82c3ebfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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