File: unwrap_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (29 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'spec_helper'

require 'puppet_spec/compiler'
require 'matchers/resource'

describe 'the unwrap function' do
  include PuppetSpec::Compiler
  include Matchers::Resource

  it 'unwraps a sensitive value' do
    code = <<-CODE
      $sensitive = Sensitive.new("12345")
      notice("unwrapped value is ${sensitive.unwrap}")
    CODE
    expect(eval_and_collect_notices(code)).to eq(['unwrapped value is 12345'])
  end

  it 'unwraps a sensitive value when given a code block' do
    code = <<-CODE
      $sensitive = Sensitive.new("12345")
      $split = $sensitive.unwrap |$unwrapped| {
        notice("unwrapped value is $unwrapped")
        $unwrapped.split(/3/)
      }
      notice("split is $split")
    CODE
    expect(eval_and_collect_notices(code)).to eq(['unwrapped value is 12345', 'split is [12, 45]'])
  end
end