|
1 | 1 | #! /usr/bin/env ruby -S rspec |
2 | 2 | require 'spec_helper_acceptance' |
3 | | -require 'shellwords' |
4 | 3 |
|
5 | 4 | 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) |
8 | 18 | end |
9 | 19 |
|
10 | 20 | context 'with --strict=error', if: get_puppet_version =~ /^4/ do |
11 | 21 | 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) |
17 | 27 | end |
18 | 28 |
|
19 | 29 | it "should return an error" do |
|
24 | 34 | expect(@result.stderr).to match(/deprecation. key. message/) |
25 | 35 | end |
26 | 36 |
|
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 } |
29 | 39 | end |
30 | 40 | end |
31 | 41 |
|
32 | 42 | context 'with --strict=warning', if: get_puppet_version =~ /^4/ do |
33 | 43 | 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) |
39 | 49 | end |
40 | 50 |
|
41 | 51 | it "should not return an error" do |
|
46 | 56 | expect(@result.stderr).to match(/Warning: message/) |
47 | 57 | end |
48 | 58 |
|
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 } |
51 | 61 | end |
52 | 62 | end |
53 | 63 |
|
54 | 64 | context 'with --strict=off', if: get_puppet_version =~ /^4/ do |
55 | 65 | 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) |
61 | 71 | end |
62 | 72 |
|
63 | 73 | it "should not return an error" do |
|
68 | 78 | expect(@result.stderr).not_to match(/Warning: message/) |
69 | 79 | end |
70 | 80 |
|
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 } |
73 | 83 | end |
74 | 84 | end |
75 | 85 | end |
0 commit comments