[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Daniel Pittman daniel at puppetlabs.com
Tue May 10 08:17:22 UTC 2011


The following commit has been merged in the experimental branch:
commit 601baf1f25e5f62b5f501635cf49721187045f29
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Tue Apr 19 20:43:47 2011 -0700

    maint: remove redundant context from the test.
    
    We had a block of tests in a describe block inside a describe block; they were
    literally one hundred percent overlap.  Eliminate that and just keep the
    outer.
    
    Reviewed-By: Max Martin <max at puppetlabs.com>

diff --git a/spec/unit/application/face_base_spec.rb b/spec/unit/application/face_base_spec.rb
index 5403608..7dbe59f 100755
--- a/spec/unit/application/face_base_spec.rb
+++ b/spec/unit/application/face_base_spec.rb
@@ -40,126 +40,124 @@ describe Puppet::Application::FaceBase do
       app.command_line.stubs(:args).returns %w{}
     end
 
-    describe "parsing the command line" do
-      context "with just an action" do
-        before :all do
-          # We have to stub Signal.trap to avoid a crazy mess where we take
-          # over signal handling and make it impossible to cancel the test
-          # suite run.
-          #
-          # It would be nice to fix this elsewhere, but it is actually hard to
-          # capture this in rspec 2.5 and all. :(  --daniel 2011-04-08
-          Signal.stubs(:trap)
-          app.command_line.stubs(:args).returns %w{foo}
-          app.preinit
-          app.parse_options
-        end
-
-        it "should set the face based on the type" do
-          app.face.name.should == :basetest
-        end
-
-        it "should find the action" do
-          app.action.should be
-          app.action.name.should == :foo
-        end
+    context "with just an action" do
+      before :all do
+        # We have to stub Signal.trap to avoid a crazy mess where we take
+        # over signal handling and make it impossible to cancel the test
+        # suite run.
+        #
+        # It would be nice to fix this elsewhere, but it is actually hard to
+        # capture this in rspec 2.5 and all. :(  --daniel 2011-04-08
+        Signal.stubs(:trap)
+        app.command_line.stubs(:args).returns %w{foo}
+        app.preinit
+        app.parse_options
       end
 
-      it "should use the default action if not given any arguments" do
-        app.command_line.stubs(:args).returns []
-        action = stub(:options => [])
-        Puppet::Face[:basetest, '0.0.1'].expects(:get_default_action).returns(action)
-        app.stubs(:main)
-        app.run
-        app.action.should == action
-        app.arguments.should == [ { } ]
+      it "should set the face based on the type" do
+        app.face.name.should == :basetest
       end
 
-      it "should use the default action if not given a valid one" do
-        app.command_line.stubs(:args).returns %w{bar}
-        action = stub(:options => [])
-        Puppet::Face[:basetest, '0.0.1'].expects(:get_default_action).returns(action)
-        app.stubs(:main)
-        app.run
-        app.action.should == action
-        app.arguments.should == [ 'bar', { } ]
+      it "should find the action" do
+        app.action.should be
+        app.action.name.should == :foo
       end
+    end
 
-      it "should have no action if not given a valid one and there is no default action" do
-        app.command_line.stubs(:args).returns %w{bar}
-        Puppet::Face[:basetest, '0.0.1'].expects(:get_default_action).returns(nil)
-        app.stubs(:main)
-        app.run
-        app.action.should be_nil
-        app.arguments.should == [ 'bar', { } ]
-      end
+    it "should use the default action if not given any arguments" do
+      app.command_line.stubs(:args).returns []
+      action = stub(:options => [])
+      Puppet::Face[:basetest, '0.0.1'].expects(:get_default_action).returns(action)
+      app.stubs(:main)
+      app.run
+      app.action.should == action
+      app.arguments.should == [ { } ]
+    end
 
-      it "should report a sensible error when options with = fail" do
-        app.command_line.stubs(:args).returns %w{--action=bar foo}
-        expect { app.preinit; app.parse_options }.
-          to raise_error OptionParser::InvalidOption, /invalid option: --action/
-      end
+    it "should use the default action if not given a valid one" do
+      app.command_line.stubs(:args).returns %w{bar}
+      action = stub(:options => [])
+      Puppet::Face[:basetest, '0.0.1'].expects(:get_default_action).returns(action)
+      app.stubs(:main)
+      app.run
+      app.action.should == action
+      app.arguments.should == [ 'bar', { } ]
+    end
 
-      it "should fail if an action option is before the action" do
-        app.command_line.stubs(:args).returns %w{--action foo}
-        expect { app.preinit; app.parse_options }.
-          to raise_error OptionParser::InvalidOption, /invalid option: --action/
-      end
+    it "should have no action if not given a valid one and there is no default action" do
+      app.command_line.stubs(:args).returns %w{bar}
+      Puppet::Face[:basetest, '0.0.1'].expects(:get_default_action).returns(nil)
+      app.stubs(:main)
+      app.run
+      app.action.should be_nil
+      app.arguments.should == [ 'bar', { } ]
+    end
 
-      it "should fail if an unknown option is before the action" do
-        app.command_line.stubs(:args).returns %w{--bar foo}
-        expect { app.preinit; app.parse_options }.
-          to raise_error OptionParser::InvalidOption, /invalid option: --bar/
-      end
+    it "should report a sensible error when options with = fail" do
+      app.command_line.stubs(:args).returns %w{--action=bar foo}
+      expect { app.preinit; app.parse_options }.
+        to raise_error OptionParser::InvalidOption, /invalid option: --action/
+    end
 
-      it "should fail if an unknown option is after the action" do
-        app.command_line.stubs(:args).returns %w{foo --bar}
-        expect { app.preinit; app.parse_options }.
-          to raise_error OptionParser::InvalidOption, /invalid option: --bar/
-      end
+    it "should fail if an action option is before the action" do
+      app.command_line.stubs(:args).returns %w{--action foo}
+      expect { app.preinit; app.parse_options }.
+        to raise_error OptionParser::InvalidOption, /invalid option: --action/
+    end
+
+    it "should fail if an unknown option is before the action" do
+      app.command_line.stubs(:args).returns %w{--bar foo}
+      expect { app.preinit; app.parse_options }.
+        to raise_error OptionParser::InvalidOption, /invalid option: --bar/
+    end
+
+    it "should fail if an unknown option is after the action" do
+      app.command_line.stubs(:args).returns %w{foo --bar}
+      expect { app.preinit; app.parse_options }.
+        to raise_error OptionParser::InvalidOption, /invalid option: --bar/
+    end
+
+    it "should accept --bar as an argument to a mandatory option after action" do
+      app.command_line.stubs(:args).returns %w{foo --mandatory --bar}
+      app.preinit
+      app.parse_options
+      app.action.name.should == :foo
+      app.options.should == { :mandatory => "--bar" }
+    end
+
+    it "should accept --bar as an argument to a mandatory option before action" do
+      app.command_line.stubs(:args).returns %w{--mandatory --bar foo}
+      app.preinit
+      app.parse_options
+      app.action.name.should == :foo
+      app.options.should == { :mandatory => "--bar" }
+    end
+
+    it "should not skip when --foo=bar is given" do
+      app.command_line.stubs(:args).returns %w{--mandatory=bar --bar foo}
+      expect { app.preinit; app.parse_options }.
+        to raise_error OptionParser::InvalidOption, /invalid option: --bar/
+    end
 
-      it "should accept --bar as an argument to a mandatory option after action" do
-        app.command_line.stubs(:args).returns %w{foo --mandatory --bar}
+    { "boolean options before" => %w{--trace foo},
+      "boolean options after"  => %w{foo --trace}
+    }.each do |name, args|
+      it "should accept global boolean settings #{name} the action" do
+        app.command_line.stubs(:args).returns args
         app.preinit
         app.parse_options
-        app.action.name.should == :foo
-        app.options.should == { :mandatory => "--bar" }
+        Puppet[:trace].should be_true
       end
+    end
 
-      it "should accept --bar as an argument to a mandatory option before action" do
-        app.command_line.stubs(:args).returns %w{--mandatory --bar foo}
+    { "before" => %w{--syslogfacility user1 foo},
+      " after" => %w{foo --syslogfacility user1}
+    }.each do |name, args|
+      it "should accept global settings with arguments #{name} the action" do
+        app.command_line.stubs(:args).returns args
         app.preinit
         app.parse_options
-        app.action.name.should == :foo
-        app.options.should == { :mandatory => "--bar" }
-      end
-
-      it "should not skip when --foo=bar is given" do
-        app.command_line.stubs(:args).returns %w{--mandatory=bar --bar foo}
-        expect { app.preinit; app.parse_options }.
-          to raise_error OptionParser::InvalidOption, /invalid option: --bar/
-      end
-
-      { "boolean options before" => %w{--trace foo},
-        "boolean options after"  => %w{foo --trace}
-      }.each do |name, args|
-        it "should accept global boolean settings #{name} the action" do
-          app.command_line.stubs(:args).returns args
-          app.preinit
-          app.parse_options
-          Puppet[:trace].should be_true
-        end
-      end
-
-      { "before" => %w{--syslogfacility user1 foo},
-        " after" => %w{foo --syslogfacility user1}
-      }.each do |name, args|
-        it "should accept global settings with arguments #{name} the action" do
-          app.command_line.stubs(:args).returns args
-          app.preinit
-          app.parse_options
-          Puppet[:syslogfacility].should == "user1"
-        end
+        Puppet[:syslogfacility].should == "user1"
       end
     end
   end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list