In configurer_spec.rb, replaced some mock classes with actual
Puppet::Transaction::Report objects.  In log_spec.rb, stopped using
the Array type as a log destination, since doing so was unreliable.

Signed-off-by: Paul Berry <p...@puppetlabs.com>
---
Local-branch: maint/next/log_refactoring
 spec/unit/configurer_spec.rb |   25 +++++++++++--------------
 spec/unit/util/log_spec.rb   |    2 +-
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/spec/unit/configurer_spec.rb b/spec/unit/configurer_spec.rb
index 0c9d063..2f8e615 100755
--- a/spec/unit/configurer_spec.rb
+++ b/spec/unit/configurer_spec.rb
@@ -89,9 +89,6 @@ describe Puppet::Configurer, "when executing a catalog run" do
     @catalog = Puppet::Resource::Catalog.new
     @catalog.stubs(:apply)
     @agent.stubs(:retrieve_catalog).returns @catalog
-
-    Puppet::Util::Log.stubs(:newdestination)
-    Puppet::Util::Log.stubs(:close)
   end
 
   it "should prepare for the run" do
@@ -101,14 +98,14 @@ describe Puppet::Configurer, "when executing a catalog 
run" do
   end
 
   it "should initialize a transaction report if one is not provided" do
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.expects(:initialize_report).returns report
 
     @agent.run
   end
 
   it "should pass the new report to the catalog" do
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.stubs(:initialize_report).returns report
     @catalog.expects(:apply).with{|options| options[:report] == report}
 
@@ -116,7 +113,7 @@ describe Puppet::Configurer, "when executing a catalog run" 
do
   end
 
   it "should use the provided report if it was passed one" do
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.expects(:initialize_report).never
     @catalog.expects(:apply).with{|options| options[:report] == report}
 
@@ -176,7 +173,7 @@ describe Puppet::Configurer, "when executing a catalog run" 
do
   end
 
   it "should send the report" do
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.expects(:initialize_report).returns report
     @agent.expects(:send_report).with { |r, trans| r == report }
 
@@ -184,7 +181,7 @@ describe Puppet::Configurer, "when executing a catalog run" 
do
   end
 
   it "should send the transaction report with a reference to the transaction 
if a run was actually made" do
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.expects(:initialize_report).returns report
 
     trans = stub 'transaction'
@@ -198,7 +195,7 @@ describe Puppet::Configurer, "when executing a catalog run" 
do
   it "should send the transaction report even if the catalog could not be 
retrieved" do
     @agent.expects(:retrieve_catalog).returns nil
 
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.expects(:initialize_report).returns report
     @agent.expects(:send_report)
 
@@ -208,7 +205,7 @@ describe Puppet::Configurer, "when executing a catalog run" 
do
   it "should send the transaction report even if there is a failure" do
     @agent.expects(:retrieve_catalog).raises "whatever"
 
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.expects(:initialize_report).returns report
     @agent.expects(:send_report)
 
@@ -216,16 +213,16 @@ describe Puppet::Configurer, "when executing a catalog 
run" do
   end
 
   it "should remove the report as a log destination when the run is finished" 
do
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.expects(:initialize_report).returns report
-
-    Puppet::Util::Log.expects(:close).with(report)
+    report.expects(:<<).at_least_once
 
     @agent.run
+    Puppet::Util::Log.destinations.should_not include(report)
   end
 
   it "should return the report as the result of the run" do
-    report = stub 'report'
+    report = Puppet::Transaction::Report.new
     @agent.expects(:initialize_report).returns report
 
     @agent.run.should equal(report)
diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb
index 7d96fe1..4cec710 100755
--- a/spec/unit/util/log_spec.rb
+++ b/spec/unit/util/log_spec.rb
@@ -87,7 +87,7 @@ describe Puppet::Util::Log do
     it "should flush the log queue when the first destination is specified" do
       Puppet::Util::Log.close_all
       Puppet::Util::Log.expects(:flushqueue)
-      Puppet::Util::Log.newdestination([])
+      Puppet::Util::Log.newdestination(:console)
     end
 
     it "should convert the level to a symbol if it's passed in as a string" do
-- 
1.7.2

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to