diff options
author | Claire McQuin <claire@getchef.com> | 2014-11-21 13:02:17 -0800 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-12-17 18:52:02 -0800 |
commit | c4333485de9dc373ad9d846332cbd897da306ff3 (patch) | |
tree | 5d9140a77d14e1f2f621d7b2f47e9939f1d00af8 | |
parent | f7e9523dc1c47b935c8921225bac514ca2eb6337 (diff) | |
download | chef-c4333485de9dc373ad9d846332cbd897da306ff3.tar.gz |
Raise error if duplicate controls block given.
-rw-r--r-- | lib/chef/dsl/audit.rb | 11 |
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 |