Permalink
Browse files

fix regexp in portage package provider

  • Loading branch information...
1 parent a1f08c7 commit e5dc027d13aa26a8c9acdb595c69b4c1aafe3f46 @veszig veszig committed with fujin Sep 20, 2009
Showing with 5 additions and 5 deletions.
  1. +1 −1 chef/lib/chef/provider/package/portage.rb
  2. +4 −4 chef/spec/unit/provider/package/portage_spec.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
@@ -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

0 comments on commit e5dc027

Please sign in to comment.