Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix regexp in portage package provider

  • Loading branch information...
commit e5dc027d13aa26a8c9acdb595c69b4c1aafe3f46 1 parent a1f08c7
@veszig veszig authored fujin committed
View
2  chef/lib/chef/provider/package/portage.rb
@@ -38,7 +38,7 @@ def load_current_resource
if( ::File.exists?(catdir) )
Dir.entries(catdir).each do |entry|
- if(entry =~ /^#{Regexp.escape(pkg)}\-(.+)/)
+ if(entry =~ /^#{Regexp.escape(pkg)}\-(\d[\.\d]*((_(alpha|beta|pre|rc|p)\d*)*)?)/)
@current_resource.version($1)
Chef::Log.debug("Got current version #{$1}")
break
View
8 chef/spec/unit/provider/package/portage_spec.rb
@@ -54,13 +54,13 @@
@provider.load_current_resource
end
- it "should return a current resource with a nil version if the package is not found" do
- ::Dir.stub!(:entries).and_return("git-1.0.0")
+ it "should return a current resource with the correct version if the package is found" do
+ ::Dir.stub!(:entries).and_return(["git-foobar-0.9", "git-1.0.0"])
@current_resource.should_receive(:version).with("1.0.0")
@provider.load_current_resource
end
-
- it "should return a current resource with the correct version if the package is found" do
+
+ it "should return a current resource with a nil version if the package is not found" do
::Dir.stub!(:entries).and_return("notgit-1.0.0")
@current_resource.should_receive(:version).with(nil)
@provider.load_current_resource
Please sign in to comment.
Something went wrong with that request. Please try again.