diff options
author | tyler-ball <tyleraball@gmail.com> | 2014-11-06 07:33:35 -0800 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-11-06 07:33:35 -0800 |
commit | 77d9188dbab8f6485d077b09abba61a28414685f (patch) | |
tree | 729dba16dbcc3685b15a8a64a04bbfeedc8da361 /lib | |
parent | adb24698e9b7d9cf62a908e04192ba3d06850492 (diff) | |
download | chef-77d9188dbab8f6485d077b09abba61a28414685f.tar.gz |
Preparing for demo - using rspec documentation formatter for output instead of the proxy
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/audit/chef_example_group.rb | 7 | ||||
-rw-r--r-- | lib/chef/audit/runner.rb | 13 | ||||
-rw-r--r-- | lib/chef/dsl/audit.rb | 8 | ||||
-rw-r--r-- | lib/chef/formatters/doc.rb | 6 |
4 files changed, 22 insertions, 12 deletions
diff --git a/lib/chef/audit/chef_example_group.rb b/lib/chef/audit/chef_example_group.rb index cd874d57b7..99bb7f8a65 100644 --- a/lib/chef/audit/chef_example_group.rb +++ b/lib/chef/audit/chef_example_group.rb @@ -2,9 +2,12 @@ require 'rspec/core' class Chef class Audit - class ChefExampleGroup < ::RSpec::Core::ExampleGroup + class ChefExampleGroup + # Can encompass tests in a `control` block or `describe` block - define_example_group_method :control + ::RSpec::Core::ExampleGroup.define_example_group_method :control + ::RSpec::Core::ExampleGroup.define_example_group_method :__controls__ + end end end diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb index 5aecc2a5d8..9c43f8ee67 100644 --- a/lib/chef/audit/runner.rb +++ b/lib/chef/audit/runner.rb @@ -48,11 +48,11 @@ class Chef # RSpec configuration and world objects are heavy, so let's wait until # we actually need them. def configuration - @configuration ||= RSpec::Core::Configuration.new + RSpec.configuration end def world - @world ||= RSpec::Core::World.new(configuration) + RSpec.world end # Configure audits before run. @@ -64,14 +64,19 @@ class Chef # Our formatter forwards events to the Chef event message bus configuration.output_stream = Chef::Config[:log_location] configuration.error_stream = Chef::Config[:log_location] + # TODO im pretty sure I only need this because im running locally in rvmsudo + configuration.backtrace_exclusion_patterns.push(Regexp.new("/Users".gsub("/", File::SEPARATOR))) + configuration.backtrace_exclusion_patterns.push(Regexp.new("(eval)")) + configuration.color = true add_formatters disable_should_syntax end def add_formatters - configuration.add_formatter(Chef::Audit::AuditEventProxy) - Chef::Audit::AuditEventProxy.events = run_context.events + configuration.add_formatter(RSpec::Core::Formatters::DocumentationFormatter) + #configuration.add_formatter(Chef::Audit::AuditEventProxy) + #Chef::Audit::AuditEventProxy.events = run_context.events end # Explicitly disable :should syntax. diff --git a/lib/chef/dsl/audit.rb b/lib/chef/dsl/audit.rb index a417e51b5d..c281b91621 100644 --- a/lib/chef/dsl/audit.rb +++ b/lib/chef/dsl/audit.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -#require 'chef/audit' + require 'chef/audit/chef_example_group' class Chef @@ -23,10 +23,10 @@ class Chef module Audit # Adds the controls group and block (containing controls to execute) to the runner's list of pending examples - def controls(group_name, &group_block) - raise ::Chef::Exceptions::NoAuditsProvided unless group_block + def controls(*args, &block) + raise ::Chef::Exceptions::NoAuditsProvided unless block - run_context.controls_groups << ::Chef::Audit::ChefExampleGroup.describe(group_name, &group_block) + run_context.controls_groups << ::RSpec::Core::ExampleGroup.__controls__(*args, &block) end end diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb index 96ca283b9f..d9c9124713 100644 --- a/lib/chef/formatters/doc.rb +++ b/lib/chef/formatters/doc.rb @@ -164,18 +164,20 @@ class Chef # Called before audit phase starts def audit_phase_start(run_context) puts_line "" - puts_line "Audit phase starting" + puts_line "++ Audit phase starting ++" end # Called when audit phase successfully finishes def audit_phase_complete - puts_line "Audit phase ended" + puts_line "" + puts_line "++ Audit phase ended ++ " end # Called if there is an uncaught exception during the audit phase. The audit runner should # be catching and handling errors from the examples, so this is only uncaught errors (like # bugs in our handling code) def audit_phase_failed(error) + puts_line "" puts_line "Audit phase exception:" indent # TODO error_mapper ? |