spec/yum_spec.rb in linux_admin-0.1.3 vs spec/yum_spec.rb in linux_admin-0.2.0

- old
+ new

@@ -5,24 +5,24 @@ FileUtils.stub(:mkdir_p => true) end context ".create_repo" do it "default arguments" do - described_class.should_receive(:run).once.with("yum createrepo", {:params=>{nil=>"some/path", "--database"=>nil, "--unique-md-filenames"=>nil}}).and_return true - expect(described_class.create_repo("some/path")).to be_true + described_class.should_receive(:run!).once.with("yum createrepo", {:params=>{nil=>"some/path", "--database"=>nil, "--unique-md-filenames"=>nil}}) + described_class.create_repo("some/path") end it "bare create" do - described_class.should_receive(:run).once.with("yum createrepo", {:params=>{nil=>"some/path"}}).and_return true - expect(described_class.create_repo("some/path", :database => false, :unique_file_names => false)).to be_true + described_class.should_receive(:run!).once.with("yum createrepo", {:params=>{nil=>"some/path"}}) + described_class.create_repo("some/path", :database => false, :unique_file_names => false) end end context ".download_packages" do it "with valid input" do - described_class.should_receive(:run).once.with("yum repotrack", {:params=>{"-p"=>"some/path", nil=>"pkg_a pkg_b"}}).and_return true - expect(described_class.download_packages("some/path", "pkg_a pkg_b")).to be_true + described_class.should_receive(:run!).once.with("yum repotrack", {:params=>{"-p"=>"some/path", nil=>"pkg_a pkg_b"}}) + described_class.download_packages("some/path", "pkg_a pkg_b") end it "without mirror type" do expect { described_class.download_packages("some/path", "pkg_a pkg_b", :mirror_type => nil) }.to raise_error(ArgumentError) end @@ -66,53 +66,53 @@ "metadata_expire" =>1}},}) end context ".updates_available?" do it "check updates for a specific package" do - described_class.should_receive(:run).once.with("yum check-update", {:params=>{nil=>["abc"]}, :return_exitstatus=>true}).and_return(100) + described_class.should_receive(:run).once.with("yum check-update", {:params=>{nil=>["abc"]}}).and_return(double(:exit_status => 100)) expect(described_class.updates_available?("abc")).to be_true end it "updates are available" do - described_class.stub(:run => 100) + described_class.stub(:run => double(:exit_status => 100)) expect(described_class.updates_available?).to be_true end it "updates not available" do - described_class.stub(:run => 0) + described_class.stub(:run => double(:exit_status => 0)) expect(described_class.updates_available?).to be_false end it "other exit code" do - described_class.stub(:run => 255) + described_class.stub(:run => double(:exit_status => 255)) expect { described_class.updates_available? }.to raise_error end it "other error" do described_class.stub(:run).and_raise(RuntimeError) - expect { described_class.updates_available? }.to raise_error + expect { described_class.updates_available? }.to raise_error(RuntimeError) end end context ".update" do it "no arguments" do - described_class.should_receive(:run).once.with("yum -y update", {:params=>nil}).and_return(0) + described_class.should_receive(:run!).once.with("yum -y update", {:params=>nil}) described_class.update end it "with arguments" do - described_class.should_receive(:run).once.with("yum -y update", {:params=>{nil=>["1 2", "3"]}}).and_return(0) + described_class.should_receive(:run!).once.with("yum -y update", {:params=>{nil=>["1 2", "3"]}}) described_class.update("1 2", "3") end end context ".version_available" do it "no packages" do expect { described_class.version_available }.to raise_error(ArgumentError) end it "with packages" do - described_class.should_receive(:run).once.with("repoquery --qf=\"%{name} %{version}\"", {:params=>{nil=>["curl"]}, :return_output=>true}).and_return(sample_output("yum/output_repoquery")) + described_class.should_receive(:run!).once.with("repoquery --qf=\"%{name} %{version}\"", {:params=>{nil=>["curl"]}}).and_return(double(:output => sample_output("yum/output_repoquery"))) expect(described_class.version_available("curl")).to eq({ "curl" => "7.19.7", "subscription-manager" => "1.1.23.1", "wget" => "1.12" }) \ No newline at end of file