From 0bd9272b1c678cbad401e8cd5096e168dd5b3b95 Mon Sep 17 00:00:00 2001 From: Matthew Kent Date: Tue, 3 May 2011 08:56:55 -0700 Subject: CHEF-2283: Support an already parsed version for speed. --- chef/spec/unit/provider/package/yum_spec.rb | 34 ++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'chef/spec') diff --git a/chef/spec/unit/provider/package/yum_spec.rb b/chef/spec/unit/provider/package/yum_spec.rb index 05a543d4f2..fde3f2f976 100644 --- a/chef/spec/unit/provider/package/yum_spec.rb +++ b/chef/spec/unit/provider/package/yum_spec.rb @@ -359,7 +359,7 @@ describe Chef::Provider::Package::Yum::RPMUtils do end describe Chef::Provider::Package::Yum::RPMPackage do - describe "new" do + describe "new - with parsing" do before do @rpm = Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5", "x86_64") end @@ -379,6 +379,38 @@ describe Chef::Provider::Package::Yum::RPMPackage do end end + describe "new - no parsing" do + before do + @rpm = Chef::Provider::Package::Yum::RPMPackage.new("testing", "1", "1.6.5", "9.36.el5", "x86_64") + end + + it "should expose nevra (name-epoch-version-release-arch) available" do + @rpm.name.should == "testing" + @rpm.epoch.should == 1 + @rpm.version.should == "1.6.5" + @rpm.release.should == "9.36.el5" + @rpm.arch.should == "x86_64" + + @rpm.nevra.should == "testing-1:1.6.5-9.36.el5.x86_64" + end + + it "should output a version-release string" do + @rpm.to_s.should == "1.6.5-9.36.el5" + end + end + + it "should raise an error unless passed 3 or 5 args" do + lambda { + Chef::Provider::Package::Yum::RPMPackage.new() + }.should raise_error(ArgumentError) + lambda { + Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5", "x86_64", "extra") + }.should raise_error(ArgumentError) + lambda { + Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5", "x86_64", "extra", "extra", "extra") + }.should raise_error(ArgumentError) + end + # thanks version_class_spec.rb! describe "<=>" do it "should sort based on complete epoch-version-release data" do -- cgit v1.2.1