patch originally from Grzegorz Nosek with contributions on the test from Oliver Hookins.
checks if the current version is greater than the should version, if so, calls yum downgrade. Signed-off-by: Dan Bode <[email protected]> --- spec/unit/provider/package/yum.rb | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/spec/unit/provider/package/yum.rb b/spec/unit/provider/package/yum.rb index ddf6863..b58b688 100644 --- a/spec/unit/provider/package/yum.rb +++ b/spec/unit/provider/package/yum.rb @@ -31,21 +31,30 @@ describe provider do @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage') @provider.install end - it "should use :install to update" do + it 'should use :install to update' do @provider.expects(:install) @provider.update end - it "should be able to set version" do - @resource.stubs(:should).with(:ensure).returns "1.2" + it 'should be able to set version' do + @resource.stubs(:should).with(:ensure).returns '1.2' @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage-1.2') - @provider.stubs(:query).returns :ensure => '1.2' + @provider.stubs(:query).returns :ensure => '1.2' @provider.install end + it 'should be able to downgrade' do + @resource.stubs(:should).with(:ensure).returns '1.0' + @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :downgrade, 'mypackage-1.0') + @provider.stubs(:query).returns :ensure => '1.2' + stubs(:raise).returns true + # this is annoying that it has to raise an expcetion here + # it is because I can only stub query once and it is called twice. + lambda {[email protected]}.should raise_error(Puppet::Error) + end end describe 'when uninstalling' do - it "should use erase to purge" do - @provider.expects(:yum).with("-y", :erase, 'mypackage') + it 'should use erase to purge' do + @provider.expects(:yum).with('-y', :erase, 'mypackage') @provider.purge end it 'should use rpm to uninstall' do @@ -54,7 +63,7 @@ describe provider do end end - it "should be versionable" do + it 'should be versionable' do provider.should be_versionable end end -- 1.5.5.6 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
