diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-03-22 17:30:40 -0700 |
---|---|---|
committer | Jesse Wolfe <jes5199@gmail.com> | 2010-03-22 17:30:40 -0700 |
commit | f891ba29ffeafb5ded6fdd26ef7a5bcde219f76a (patch) | |
tree | 94426019095f051f6b49b2c4364d65aa964bc7cb /lib/puppet | |
parent | af9c19ab7fa61cc4ed423d69f76bdce5b469d237 (diff) | |
download | puppet-f891ba29ffeafb5ded6fdd26ef7a5bcde219f76a.tar.gz puppet-f891ba29ffeafb5ded6fdd26ef7a5bcde219f76a.tar.xz puppet-f891ba29ffeafb5ded6fdd26ef7a5bcde219f76a.zip |
Fixing #3407 Failing tests in spec/unit/node/environment.rb
A naked rescue in Puppet::Node::Environment was hiding expectation
violations from the Mocha mocks.
Specifically, 'modulepath' expectations were failing, as Puppet::Module now calls
Puppet::Node::Environment#modulepath internally.
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/module.rb | 20 | ||||
-rw-r--r-- | lib/puppet/node/environment.rb | 8 |
2 files changed, 15 insertions, 13 deletions
diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index b0d80caa6..f30b862ef 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -2,20 +2,16 @@ require 'puppet/util/logging' # Support for modules class Puppet::Module - class MissingModule < Puppet::Error; end - class IncompatibleModule < Puppet::Error; end - class UnsupportedPlatform < Puppet::Error; end - class IncompatiblePlatform < Puppet::Error; end - class MissingMetadata < Puppet::Error; end + class Error < Puppet::Error; end + class MissingModule < Error; end + class IncompatibleModule < Error; end + class UnsupportedPlatform < Error; end + class IncompatiblePlatform < Error; end + class MissingMetadata < Error; end + class InvalidName < Error; end include Puppet::Util::Logging - class InvalidName < ArgumentError - def message - "Invalid module name; module names must be alphanumeric (plus '-')" - end - end - TEMPLATES = "templates" FILES = "files" MANIFESTS = "manifests" @@ -215,6 +211,6 @@ class Puppet::Module end def assert_validity - raise InvalidName unless name =~ /^[-\w]+$/ + raise InvalidName, "Invalid module name; module names must be alphanumeric (plus '-')" unless name =~ /^[-\w]+$/ end end diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index 94f899200..395d50657 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -62,7 +62,13 @@ class Puppet::Node::Environment # Cache the list, because it can be expensive to create. cached_attr(:modules, :ttl => Puppet[:filetimeout]) do module_names = modulepath.collect { |path| Dir.entries(path) }.flatten.uniq - module_names.collect { |path| Puppet::Module.new(path, self) rescue nil }.compact + module_names.collect do |path| + begin + Puppet::Module.new(path, self) + rescue Puppet::Module::Error => e + nil + end + end.compact end # Cache the manifestdir, so that we aren't searching through |