summaryrefslogtreecommitdiff
path: root/lib/chef/dsl
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-11-21 13:02:17 -0800
committertyler-ball <tyleraball@gmail.com>2014-12-17 18:52:02 -0800
commitc4333485de9dc373ad9d846332cbd897da306ff3 (patch)
tree5d9140a77d14e1f2f621d7b2f47e9939f1d00af8 /lib/chef/dsl
parentf7e9523dc1c47b935c8921225bac514ca2eb6337 (diff)
downloadchef-c4333485de9dc373ad9d846332cbd897da306ff3.tar.gz
Raise error if duplicate controls block given.
Diffstat (limited to 'lib/chef/dsl')
-rw-r--r--lib/chef/dsl/audit.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/dsl/audit.rb b/lib/chef/dsl/audit.rb
index 72a1752df2..e22c38f587 100644
--- a/lib/chef/dsl/audit.rb
+++ b/lib/chef/dsl/audit.rb
@@ -16,6 +16,8 @@
# limitations under the License.
#
+require 'chef/exceptions'
+
class Chef
module DSL
module Audit
@@ -23,9 +25,14 @@ class Chef
# Can encompass tests in a `control` block or `describe` block
# Adds the controls group and block (containing controls to execute) to the runner's list of pending examples
def controls(*args, &block)
- raise ::Chef::Exceptions::NoAuditsProvided unless block
+ raise Chef::Exceptions::NoAuditsProvided unless block
+
name = args[0]
- raise AuditNameMissing if name.nil? || name.empty?
+ if name.nil? || name.empty?
+ raise Chef::Exceptions::AuditNameMissing
+ elsif run_context.controls.has_key?(name)
+ raise Chef::Exceptions::AuditControlGroupDuplicate.new(name)
+ end
run_context.controls[name] = { :args => args, :block => block }
end