source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/spec/functions/deprecation_spec.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 7 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

File size: 2.0 KB
Line 
1require 'spec_helper'
2
3if Puppet.version.to_f >= 4.0
4 describe 'deprecation' do
5 before(:each) {
6 # this is to reset the strict variable to default
7 Puppet.settings[:strict] = :warning
8 }
9
10 it { is_expected.not_to eq(nil) }
11 it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
12
13 it 'should display a single warning' do
14 Puppet.expects(:warning).with(includes('heelo'))
15 is_expected.to run.with_params('key', 'heelo')
16 end
17
18 it 'should display a single warning, despite multiple calls' do
19 Puppet.expects(:warning).with(includes('heelo')).once
20 is_expected.to run.with_params('key', 'heelo')
21 is_expected.to run.with_params('key', 'heelo')
22 end
23
24 it 'should fail twice with message, with multiple calls. when strict= :error' do
25 Puppet.settings[:strict] = :error
26 Puppet.expects(:warning).with(includes('heelo')).never
27 is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, /deprecation. key. heelo/)
28 is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, /deprecation. key. heelo/)
29 end
30
31 it 'should display nothing, despite multiple calls. strict= :off' do
32 Puppet.settings[:strict] = :off
33 Puppet.expects(:warning).with(includes('heelo')).never
34 is_expected.to run.with_params('key', 'heelo')
35 is_expected.to run.with_params('key', 'heelo')
36 end
37
38 after(:all) {
39 # this is to reset the strict variable to default
40 Puppet.settings[:strict] = :warning
41 }
42 end
43else
44 describe 'deprecation' do
45 after(:all) do
46 ENV.delete('STDLIB_LOG_DEPRECATIONS')
47 end
48 ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
49 it { is_expected.not_to eq(nil) }
50 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
51
52 it 'should display a single warning' do
53 scope.expects(:warning).with(includes('heelo'))
54 is_expected.to run.with_params('key', 'heelo')
55 end
56 end
57end
Note: See TracBrowser for help on using the repository browser.