X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Ftime_spec.rb;h=239e2ab09381563a20be8cf56c644a1ac2c57a07;hb=59812388abf4638d6065ffda934d1866af902302;hp=d157939e9ea2e02fdfb51bdfdc3958f98c15b17f;hpb=6963202b4b62c2816655ac9532521b018fdf83bd;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/spec/functions/time_spec.rb b/3rdparty/modules/stdlib/spec/functions/time_spec.rb old mode 100755 new mode 100644 index d157939e9..239e2ab09 --- a/3rdparty/modules/stdlib/spec/functions/time_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/time_spec.rb @@ -2,20 +2,20 @@ require 'spec_helper' describe 'time' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } context 'when running at a specific time' do - before(:each) { + before(:each) do # get a value before stubbing the function test_time = Time.utc(2006, 10, 13, 8, 15, 11) - Time.expects(:new).with().returns(test_time).once - } - it { is_expected.to run.with_params().and_return(1160727311) } - it { is_expected.to run.with_params('').and_return(1160727311) } - it { is_expected.to run.with_params([]).and_return(1160727311) } - it { is_expected.to run.with_params({}).and_return(1160727311) } - it { is_expected.to run.with_params('foo').and_return(1160727311) } - it { is_expected.to run.with_params('UTC').and_return(1160727311) } - it { is_expected.to run.with_params('America/New_York').and_return(1160727311) } + allow(Time).to receive(:new).with(no_args).and_return(test_time).once + end + it { is_expected.to run.with_params.and_return(1_160_727_311) } + it { is_expected.to run.with_params('').and_return(1_160_727_311) } + it { is_expected.to run.with_params([]).and_return(1_160_727_311) } + it { is_expected.to run.with_params({}).and_return(1_160_727_311) } + it { is_expected.to run.with_params('foo').and_return(1_160_727_311) } + it { is_expected.to run.with_params('UTC').and_return(1_160_727_311) } + it { is_expected.to run.with_params('America/New_York').and_return(1_160_727_311) } end end