Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / is_string_spec.rb
1 require 'spec_helper'
2
3 describe 'is_string' do
4
5   it { is_expected.not_to eq(nil) }
6   it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
7   it {
8     pending("Current implementation ignores parameters after the first.")
9     is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
10   }
11
12   it { is_expected.to run.with_params(3).and_return(false) }
13   it { is_expected.to run.with_params('3').and_return(false) }
14   it { is_expected.to run.with_params(-3).and_return(false) }
15   it { is_expected.to run.with_params('-3').and_return(false) }
16
17   it { is_expected.to run.with_params(3.7).and_return(false) }
18   it { is_expected.to run.with_params('3.7').and_return(false) }
19   it { is_expected.to run.with_params(-3.7).and_return(false) }
20   it { is_expected.to run.with_params('3.7').and_return(false) }
21
22   it { is_expected.to run.with_params([]).and_return(false) }
23   it { is_expected.to run.with_params([1]).and_return(false) }
24   it { is_expected.to run.with_params({}).and_return(false) }
25   it { is_expected.to run.with_params(true).and_return(false) }
26   it { is_expected.to run.with_params(false).and_return(false) }
27   it { is_expected.to run.with_params('one').and_return(true) }
28   it { is_expected.to run.with_params('0001234').and_return(true) }
29
30   context 'Checking for deprecation warning' do
31     after(:all) do
32       ENV.delete('STDLIB_LOG_DEPRECATIONS')
33     end
34     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
35     it 'should display a single deprecation' do
36       ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
37       scope.expects(:warning).with(includes('This method is deprecated'))
38       is_expected.to run.with_params('sponge').and_return(true)
39     end
40     it 'should display no warning for deprecation' do
41       ENV['STDLIB_LOG_DEPRECATIONS'] = "false"
42       scope.expects(:warning).with(includes('This method is deprecated')).never
43       is_expected.to run.with_params('bob').and_return(true)
44     end
45   end 
46
47 end