Skip to content

Commit 7b9a081

Browse files
committed
(CONT-1040) - run node_encrypt spec test in parser scope
1 parent 921ff46 commit 7b9a081

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/puppet/parser/functions/node_encrypt.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require_relative '../../../PuppetX/binford2k/node_encrypt'
3+
require_relative '../../../puppet_x/binford2k/node_encrypt'
44

55
Puppet::Parser::Functions.newfunction(:node_encrypt,
66
type: :rvalue,

spec/functions/node_encrypt_spec.rb

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
describe 'node_encrypt' do
77
let(:node) { 'testhost.example.com' }
88

9-
it {
9+
it 'exists' do
10+
expect(Puppet::Parser::Functions.function('node_encrypt')).to eq('function_node_encrypt')
11+
end
12+
13+
it 'receives foobar and returns encrypted' do
1014
expect(PuppetX::Binford2k::NodeEncrypt).to receive(:encrypt).with('foobar', 'testhost.example.com').and_return('encrypted')
11-
expect(subject).to run.with_params('foobar').and_return('encrypted')
12-
}
15+
expect(scope.function_node_encrypt(['foobar'])).to eq('encrypted')
16+
end
1317

1418
if defined?(Puppet::Pops::Types::PSensitiveType::Sensitive)
15-
it {
19+
it 'receives sensitive value and returns encrypted' do
1620
expect(PuppetX::Binford2k::NodeEncrypt).to receive(:encrypt).with('foobar', 'testhost.example.com').and_return('encrypted')
17-
expect(subject).to run.with_params(Puppet::Pops::Types::PSensitiveType::Sensitive.new('foobar')).and_return('encrypted')
18-
}
21+
expect(scope.function_node_encrypt([Puppet::Pops::Types::PSensitiveType::Sensitive.new('foobar')])).to eq('encrypted')
22+
end
1923
end
2024
end

0 commit comments

Comments
 (0)