Skip to content

Commit cf80dc4

Browse files
committed
Implement spec test for fail_on_transport
This commit updates the fail_on_transport_spec.rb file to contain a fully implemented test instead of an outline stubbed out with `xif`.
1 parent bfbeed4 commit cf80dc4

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

spec/functions/fail_on_transport_spec.rb

+27-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,35 @@
33
require 'spec_helper'
44

55
describe 'peadm::fail_on_transport' do
6+
include BoltSpec::BoltContext
7+
8+
around :each do |example|
9+
in_bolt_context do
10+
example.run
11+
end
12+
end
13+
14+
# NOTE: If https://github.com/puppetlabs/bolt/issues/3184
15+
# is fixed, this will start causing a duplicate declaration
16+
# error. If that happens, delete this pre_condition.
17+
let(:pre_condition) do
18+
'type TargetSpec = Boltlib::TargetSpec'
19+
end
20+
621
let(:nodes) do
7-
'some_value_goes_here'
22+
'pcp://target.example'
823
end
9-
let(:transport) do
10-
'some_value_goes_here'
24+
25+
# Function testing depends on rspec-puppet magic in the opening describe
26+
# statement. Re-defining the subject just to give it a different name
27+
# would require duplicating rspec-puppet code, and that's a far worse sin.
28+
# rubocop:disable Rspec/NamedSubject
29+
it 'raises an error when nodes use the specified transport' do
30+
expect { subject.execute(nodes, 'pcp') }.to raise_error(Puppet::PreformattedError, %r{target\.example uses pcp transport})
1131
end
1232

13-
xit { is_expected.to run.with_params(nodes, transport).and_return('some_value') }
33+
it 'raises no error when nodes do not use the specified transport' do
34+
expect { subject.execute(nodes, 'ssh') }.not_to raise_error
35+
end
36+
# rubocop:enable Rspec/NamedSubject
1437
end

0 commit comments

Comments
 (0)