diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2011-02-03 16:47:51 -0800 |
|---|---|---|
| committer | Jesse Wolfe <jes5199@gmail.com> | 2011-02-03 16:47:51 -0800 |
| commit | dd68914eb25d8dd9aac5c8ced39fa0d05136ed9f (patch) | |
| tree | b0dd0c48901a9fa339b2d8734bd7a6bca088458c /spec/unit | |
| parent | ea348761df0b5297dbac50c7f1c48d22746524fa (diff) | |
| parent | 3f2f1c2456cf5f08bd67ab5730ab970be5285711 (diff) | |
Merge branch 'maint/2.6.next/help' into next
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/application_spec.rb | 47 | ||||
| -rwxr-xr-x | spec/unit/util/log/destinations_spec.rb | 13 | ||||
| -rwxr-xr-x | spec/unit/util/log_spec.rb | 5 |
3 files changed, 62 insertions, 3 deletions
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 65f06169c..ca663e317 100755 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -46,6 +46,48 @@ describe Puppet::Application do end end + it "should sadly and frighteningly allow run_mode to change at runtime" do + class TestApp < Puppet::Application + run_mode :master + def run_command + # This is equivalent to calling these methods externally to the + # instance, but since this is what "real world" code is likely to do + # (and we need the class anyway) we may as well test that. --daniel 2011-02-03 + set_run_mode self.class.run_mode "agent" + end + end + + Puppet[:run_mode].should == "user" + + expect { + app = TestApp.new + + Puppet[:run_mode].should == "master" + + app.run + + app.class.run_mode.name.should == :agent + $puppet_application_mode.name.should == :agent + }.should_not raise_error + + Puppet[:run_mode].should == "agent" + end + + it "it should not allow run mode to be set multiple times" do + pending "great floods of tears, you can do this right now" # --daniel 2011-02-03 + app = Puppet::Application.new + expect { + app.set_run_mode app.class.run_mode "master" + $puppet_application_mode.name.should == :master + app.set_run_mode app.class.run_mode "agent" + $puppet_application_mode.name.should == :agent + }.should raise_error + end + + it "should explode when an invalid run mode is set at runtime, for great victory" + # ...but you can, and while it will explode, that only happens too late for + # us to easily test. --daniel 2011-02-03 + it "should have a run entry-point" do @app.should respond_to(:run) end @@ -241,11 +283,10 @@ describe Puppet::Application do @app.parse_options end - describe "when using --help", :if => Puppet.features.usage? do + describe "when using --help" do - it "should call RDoc::usage and exit" do + it "should call exit" do @app.expects(:exit) - RDoc.expects(:usage).returns(true) @app.handle_help(nil) end diff --git a/spec/unit/util/log/destinations_spec.rb b/spec/unit/util/log/destinations_spec.rb index 468702fb3..b84c2ab44 100755 --- a/spec/unit/util/log/destinations_spec.rb +++ b/spec/unit/util/log/destinations_spec.rb @@ -22,3 +22,16 @@ describe Puppet::Util::Log.desttypes[:report] do dest.handle "my log" end end + + +describe Puppet::Util::Log.desttypes[:file] do + before do + File.stubs(:open) # prevent actually creating the file + @class = Puppet::Util::Log.desttypes[:file] + end + + it "should default to autoflush false" do + @class.new('/tmp/log').autoflush.should == false + end +end + diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb index a6f11739b..29df0787a 100755 --- a/spec/unit/util/log_spec.rb +++ b/spec/unit/util/log_spec.rb @@ -136,6 +136,11 @@ describe Puppet::Util::Log do Puppet::Util::Log.new(:level => "notice", :message => :foo) end + it "should update Log autoflush when Puppet[:autoflush] is set" do + Puppet::Util::Log.expects(:autoflush=).once.with(true) + Puppet[:autoflush] = true + end + it "should have a method for determining if a tag is present" do Puppet::Util::Log.new(:level => "notice", :message => :foo).should respond_to(:tagged?) end |
