|
20 | 20 | end |
21 | 21 |
|
22 | 22 | it { |
23 | | - is_expected.to contain_exec('syntax verification for rspec').with('refreshonly' => 'true', |
24 | | - 'subscribe' => 'File[apache_rspec]', |
25 | | - 'command' => '/usr/sbin/apachectl -t', |
26 | | - 'notify' => 'Class[Apache::Service]', |
27 | | - 'before' => 'Exec[remove rspec if invalid]') |
| 23 | + is_expected.to contain_exec('syntax verification for rspec') |
| 24 | + .with('refreshonly' => 'true', 'command' => '/usr/sbin/apachectl -t') |
| 25 | + .that_subscribes_to('File[apache_rspec]') |
| 26 | + .that_notifies('Class[Apache::Service]') |
| 27 | + .that_comes_before('Exec[remove rspec if invalid]') |
28 | 28 | } |
29 | 29 | it { |
30 | | - is_expected.to contain_exec('remove rspec if invalid').with('unless' => '/usr/sbin/apachectl -t', |
31 | | - 'subscribe' => 'File[apache_rspec]', |
32 | | - 'refreshonly' => 'true') |
| 30 | + is_expected.to contain_exec('remove rspec if invalid') |
| 31 | + .with('unless' => '/usr/sbin/apachectl -t', 'refreshonly' => 'true') |
| 32 | + .that_subscribes_to('File[apache_rspec]') |
33 | 33 | } |
34 | 34 | it { |
35 | | - is_expected.to contain_file('apache_rspec').with('ensure' => 'present', |
36 | | - 'content' => '# Test', |
37 | | - 'require' => 'Package[httpd]') |
| 35 | + is_expected.to contain_file('apache_rspec') |
| 36 | + .with('ensure' => 'present', 'content' => '# Test') |
| 37 | + .that_requires('Package[httpd]') |
38 | 38 | } |
39 | 39 | end |
40 | 40 | context 'set everything with source' do |
|
55 | 55 | 'unless' => '/bin/true') |
56 | 56 | } |
57 | 57 | it { |
58 | | - is_expected.to contain_file('apache_rspec').with('path' => '/dne/30-rspec.conf', |
59 | | - 'ensure' => 'present', |
60 | | - 'source' => 'puppet:///modules/apache/test', |
61 | | - 'require' => 'Package[httpd]') |
| 58 | + is_expected.to contain_file('apache_rspec') |
| 59 | + .that_requires('Package[httpd]') |
| 60 | + .with('path' => '/dne/30-rspec.conf', |
| 61 | + 'ensure' => 'present', |
| 62 | + 'source' => 'puppet:///modules/apache/test') |
62 | 63 | } |
63 | 64 | end |
64 | 65 | context 'verify_config => false' do |
|
71 | 72 |
|
72 | 73 | it { is_expected.not_to contain_exec('syntax verification for rspec') } |
73 | 74 | it { is_expected.not_to contain_exec('remove rspec if invalid') } |
74 | | - it { |
75 | | - is_expected.to contain_file('apache_rspec').with('notify' => 'Class[Apache::Service]') |
76 | | - } |
| 75 | + it { is_expected.to contain_file('apache_rspec').that_notifies('Class[Apache::Service]') } |
77 | 76 | end |
78 | 77 | context 'ensure => absent' do |
79 | 78 | let :params do |
|
84 | 83 |
|
85 | 84 | it { is_expected.not_to contain_exec('syntax verification for rspec') } |
86 | 85 | it { is_expected.not_to contain_exec('remove rspec if invalid') } |
87 | | - it { |
88 | | - is_expected.to contain_file('apache_rspec').with('ensure' => 'absent') |
89 | | - } |
| 86 | + it { is_expected.to contain_file('apache_rspec').with('ensure' => 'absent') } |
90 | 87 | end |
91 | 88 | describe 'validation' do |
92 | 89 | context 'both content and source' do |
|
97 | 94 | } |
98 | 95 | end |
99 | 96 |
|
100 | | - it do |
101 | | - expect { |
102 | | - catalogue |
103 | | - }.to raise_error(Puppet::Error, %r{Only one of \$content and \$source can be specified\.}) |
104 | | - end |
| 97 | + it { is_expected.to compile.and_raise_error(%r{Only one of \$content and \$source can be specified\.}) } |
105 | 98 | end |
| 99 | + |
106 | 100 | context 'neither content nor source' do |
107 | | - it do |
108 | | - expect { |
109 | | - catalogue |
110 | | - }.to raise_error(Puppet::Error, %r{One of \$content and \$source must be specified\.}) |
111 | | - end |
| 101 | + it { is_expected.to compile.and_raise_error(%r{One of \$content and \$source must be specified\.}) } |
112 | 102 | end |
113 | 103 | end |
114 | 104 | end |
0 commit comments