From b6ef6e94142a3aa3fb13c8adac0f493e551ccebd Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Mon, 7 Oct 2013 09:18:31 -0400 Subject: [PATCH] Add LinuxAdmin::Rpm.upgrade with specs --- lib/linux_admin/rpm.rb | 7 +++++++ spec/rpm_spec.rb | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/lib/linux_admin/rpm.rb b/lib/linux_admin/rpm.rb index 129b08e..9cf1511 100644 --- a/lib/linux_admin/rpm.rb +++ b/lib/linux_admin/rpm.rb @@ -7,5 +7,12 @@ def self.list_installed pkg_hash[name] = ver end end + + def self.upgrade(pkg) + cmd = "rpm -U" + params = { nil => pkg } + + run(cmd, :params => params).exit_status == 0 + end end end diff --git a/spec/rpm_spec.rb b/spec/rpm_spec.rb index 9d1691b..85906fb 100644 --- a/spec/rpm_spec.rb +++ b/spec/rpm_spec.rb @@ -26,4 +26,9 @@ "zlib-devel" =>"1.2.3-29.el6", }) end + + it ".upgrade" do + described_class.should_receive(:run).with("rpm -U", {:params=>{nil=>"abc"}}).and_return(CommandResult.new("", "", 0)) + expect(described_class.upgrade("abc")).to be_true + end end \ No newline at end of file