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