comparison modules/stdlib/spec/functions/is_float_spec.rb @ 275:d9352a684e62

Mass update of modules to remove deprecation warnings
author IBBoard <dev@ibboard.co.uk>
date Sun, 26 Jan 2020 11:36:07 +0000
parents c42fb28cff86
children
comparison
equal deleted inserted replaced
274:b2571c28fc27 275:d9352a684e62
3 describe 'is_float' do 3 describe 'is_float' do
4 it { is_expected.not_to eq(nil) } 4 it { is_expected.not_to eq(nil) }
5 5
6 it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } 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(0.1, 0.2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } 7 it { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
8 8 it { is_expected.to run.with_params('0.1').and_return(true) }
9 describe 'passing a string' do 9 it { is_expected.to run.with_params('1.0').and_return(true) }
10 it { is_expected.to run.with_params('0.1').and_return(true) } 10 it { is_expected.to run.with_params('1').and_return(false) }
11 it { is_expected.to run.with_params('1.0').and_return(true) } 11 it { is_expected.to run.with_params('one').and_return(false) }
12 it { is_expected.to run.with_params('1').and_return(false) } 12 it { is_expected.to run.with_params('one 1.0').and_return(false) }
13 it { is_expected.to run.with_params('one').and_return(false) } 13 it { is_expected.to run.with_params('1.0 one').and_return(false) }
14 it { is_expected.to run.with_params('one 1.0').and_return(false) } 14 it { is_expected.to run.with_params(0.1).and_return(true) }
15 it { is_expected.to run.with_params('1.0 one').and_return(false) } 15 it { is_expected.to run.with_params(1.0).and_return(true) }
16 end 16 it { is_expected.to run.with_params(1).and_return(false) }
17 17 it { is_expected.to run.with_params({}).and_return(false) }
18 describe 'passing numbers' do 18 it { is_expected.to run.with_params([]).and_return(false) }
19 it { is_expected.to run.with_params(0.1).and_return(true) }
20 it { is_expected.to run.with_params(1.0).and_return(true) }
21 it { is_expected.to run.with_params(1).and_return(false) }
22 end
23 19
24 context 'with deprecation warning' do 20 context 'with deprecation warning' do
25 after(:each) do 21 after(:each) do
26 ENV.delete('STDLIB_LOG_DEPRECATIONS') 22 ENV.delete('STDLIB_LOG_DEPRECATIONS')
27 end 23 end
28 # Checking for deprecation warning, which should only be provoked when the env variable for it is set. 24 # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
29 it 'displays a single deprecation' do 25 it 'displays a single deprecation' do
30 ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' 26 ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
31 scope.expects(:warning).with(includes('This method is deprecated')) 27 expect(scope).to receive(:warning).with(include('This method is deprecated'))
32 is_expected.to run.with_params(2.2).and_return(true) 28 is_expected.to run.with_params(2.2).and_return(true)
33 end 29 end
34 it 'displays no warning for deprecation' do 30 it 'displays no warning for deprecation' do
35 ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' 31 ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
36 scope.expects(:warning).with(includes('This method is deprecated')).never 32 expect(scope).to receive(:warning).with(include('This method is deprecated')).never
37 is_expected.to run.with_params(1.0).and_return(true) 33 is_expected.to run.with_params(1.0).and_return(true)
38 end 34 end
39 end 35 end
40 end 36 end