Skip to content

Commit 5de6783

Browse files
authored
Merge pull request #646 from eputnam/deprecation_spec_fix_2
MODULES-3699 Deprecation spec fix 2
2 parents b8943f6 + d2296c9 commit 5de6783

1 file changed

Lines changed: 34 additions & 24 deletions

File tree

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper_acceptance'
3-
require 'shellwords'
43

54
describe 'deprecation function' do
6-
before :each do
7-
FileUtils.rm_rf '/tmp/deprecation'
5+
6+
if fact('operatingsystem') == 'windows'
7+
test_file = 'C:/deprecation'
8+
else
9+
test_file = "/tmp/deprecation"
10+
end
11+
12+
# It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format
13+
add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
14+
remove_file_manifest = "file { '#{test_file}': ensure => absent }"
15+
16+
before :all do
17+
apply_manifest(remove_file_manifest)
818
end
919

1020
context 'with --strict=error', if: get_puppet_version =~ /^4/ do
1121
before :all do
12-
pp = <<-EOS
13-
deprecation('key', 'message')
14-
file { '/tmp/deprecation': ensure => present }
15-
EOS
16-
@result = on(default, puppet('apply', '--strict=error', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
22+
@result = on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
23+
end
24+
25+
after :all do
26+
apply_manifest(remove_file_manifest)
1727
end
1828

1929
it "should return an error" do
@@ -24,18 +34,18 @@
2434
expect(@result.stderr).to match(/deprecation. key. message/)
2535
end
2636

27-
describe file('/tmp/deprecation') do
28-
it { is_expected.not_to exist }
37+
describe file("#{test_file}") do
38+
it { is_expected.not_to be_file }
2939
end
3040
end
3141

3242
context 'with --strict=warning', if: get_puppet_version =~ /^4/ do
3343
before :all do
34-
pp = <<-EOS
35-
deprecation('key', 'message')
36-
file { '/tmp/deprecation': ensure => present }
37-
EOS
38-
@result = on(default, puppet('apply', '--strict=warning', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
44+
@result = on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
45+
end
46+
47+
after :all do
48+
apply_manifest(remove_file_manifest)
3949
end
4050

4151
it "should not return an error" do
@@ -46,18 +56,18 @@
4656
expect(@result.stderr).to match(/Warning: message/)
4757
end
4858

49-
describe file('/tmp/deprecation') do
50-
it { is_expected.to exist }
59+
describe file("#{test_file}") do
60+
it { is_expected.to be_file }
5161
end
5262
end
5363

5464
context 'with --strict=off', if: get_puppet_version =~ /^4/ do
5565
before :all do
56-
pp = <<-EOS
57-
deprecation('key', 'message')
58-
file { '/tmp/deprecation': ensure => present }
59-
EOS
60-
@result = on(default, puppet('apply', '--strict=off', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
66+
@result = on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
67+
end
68+
69+
after :all do
70+
apply_manifest(remove_file_manifest)
6171
end
6272

6373
it "should not return an error" do
@@ -68,8 +78,8 @@
6878
expect(@result.stderr).not_to match(/Warning: message/)
6979
end
7080

71-
describe file('/tmp/deprecation') do
72-
it { is_expected.to exist }
81+
describe file("#{test_file}") do
82+
it { is_expected.to be_file }
7383
end
7484
end
7585
end

0 commit comments

Comments
 (0)