Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / is_numeric_spec.rb
1 require 'spec_helper'
2
3 describe 'is_numeric' do
4   it { is_expected.not_to eq(nil) }
5
6   it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
7   it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
8
9   it { is_expected.to run.with_params(3).and_return(true) }
10   it { is_expected.to run.with_params('3').and_return(true) }
11   it { is_expected.to run.with_params(-3).and_return(true) }
12   it { is_expected.to run.with_params('-3').and_return(true) }
13
14   it { is_expected.to run.with_params(3.7).and_return(true) }
15   it { is_expected.to run.with_params('3.7').and_return(true) }
16   it { is_expected.to run.with_params(-3.7).and_return(true) }
17   it { is_expected.to run.with_params('-3.7').and_return(true) }
18
19   it { is_expected.to run.with_params('-342.2315e-12').and_return(true) }
20
21   it { is_expected.to run.with_params('one').and_return(false) }
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('0001234').and_return(false) }
28   it { is_expected.to run.with_params(' - 1234').and_return(false) }
29   it { is_expected.to run.with_params(['aaa.com', 'bbb', 'ccc']).and_return(false) }
30
31   context 'with deprecation warning' do
32     after(:each) do
33       ENV.delete('STDLIB_LOG_DEPRECATIONS')
34     end
35     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
36     it 'displays a single deprecation' do
37       ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
38       expect(scope).to receive(:warning).with(include('This method is deprecated'))
39       is_expected.to run.with_params(7).and_return(true)
40     end
41     it 'displays no warning for deprecation' do
42       ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
43       expect(scope).to receive(:warning).with(include('This method is deprecated')).never
44       is_expected.to run.with_params(7).and_return(true)
45     end
46   end
47 end