diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-02-14 17:15:39 +0100 |
---|---|---|
committer | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-02-16 20:12:10 +0100 |
commit | 3390d8db8b1d31b52a71b9502deb0e0784cf8ade (patch) | |
tree | b7e7ba9e33abe598089b88bdf9cf21c153b385aa /spec/unit | |
parent | 8265d6eaf7dd7d4fb2af30363bfbcc698dea1436 (diff) | |
download | puppet-3390d8db8b1d31b52a71b9502deb0e0784cf8ade.tar.gz puppet-3390d8db8b1d31b52a71b9502deb0e0784cf8ade.tar.xz puppet-3390d8db8b1d31b52a71b9502deb0e0784cf8ade.zip |
Move pi to the Application Controller paradigm
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-x | spec/unit/application/pi.rb | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/spec/unit/application/pi.rb b/spec/unit/application/pi.rb new file mode 100755 index 000000000..84d6a7ff5 --- /dev/null +++ b/spec/unit/application/pi.rb @@ -0,0 +1,84 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/application/pi' + +describe "pi" do + before :each do + @pi = Puppet::Application[:pi] + end + + it "should ask Puppet::Application to not parse Puppet configuration file" do + @pi.should_parse_config?.should be_false + end + + it "should declare a main command" do + @pi.should respond_to(:main) + end + + it "should declare a preinit block" do + @pi.should respond_to(:run_preinit) + end + + [:providers,:list,:meta].each do |option| + it "should declare handle_#{option} method" do + @pi.should respond_to("handle_#{option}".to_sym) + end + + it "should store argument value when calling handle_#{option}" do + @pi.options.expects(:[]=).with("#{option}".to_sym, 'arg') + @pi.send("handle_#{option}".to_sym, 'arg') + end + end + + + describe "in preinit" do + it "should set options[:parameteers] to true" do + @pi.run_preinit + + @pi.options[:parameters].should be_true + end + end + + describe "when handling parameters" do + it "should set options[:parameters] to false" do + @pi.handle_short(nil) + + @pi.options[:parameters].should be_false + end + end + + describe "during setup" do + it "should collect ARGV in options[:types]" do + ARGV.stubs(:dup).returns(['1','2']) + @pi.run_setup + + @pi.options[:types].should == ['1','2'] + end + end + + describe "when running" do + + before :each do + @typedoc = stub 'type_doc' + TypeDoc.stubs(:new).returns(@typedoc) + end + + it "should call list_types if options list is set" do + @pi.options[:list] = true + + @typedoc.expects(:list_types) + + @pi.run_command + end + + it "should call format_type for each given types" do + @pi.options[:list] = false + @pi.options[:types] = ['type'] + + @typedoc.expects(:format_type).with('type', @pi.options) + @pi.run_command + end + end +end |