diff options
Diffstat (limited to 'spec/unit/util')
-rwxr-xr-x[-rw-r--r--] | spec/unit/util/command_line_spec.rb | 29 | ||||
-rwxr-xr-x | spec/unit/util/rdoc/parser_spec.rb | 18 |
2 files changed, 44 insertions, 3 deletions
diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb index 7ba965249..98ddb92f6 100644..100755 --- a/spec/unit/util/command_line_spec.rb +++ b/spec/unit/util/command_line_spec.rb @@ -6,6 +6,7 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f require 'puppet/util/command_line' describe Puppet::Util::CommandLine do + include PuppetSpec::Files before do @tty = stub("tty", :tty? => true ) @pipe = stub("pipe", :tty? => false) @@ -105,4 +106,32 @@ describe Puppet::Util::CommandLine do end end end + describe 'when loading commands' do + before do + @core_apps = %w{describe filebucket kick queue resource agent cert apply doc master} + @command_line = Puppet::Util::CommandLine.new("foo", %w{ client --help whatever.pp }, @tty ) + end + it 'should be able to find all existing commands' do + @core_apps.each do |command| + @command_line.available_subcommands.should include command + end + end + describe 'when multiple paths have applications' do + before do + @dir=tmpdir('command_line_plugin_test') + @appdir="#{@dir}/puppet/application" + FileUtils.mkdir_p(@appdir) + FileUtils.touch("#{@appdir}/foo.rb") + $LOAD_PATH.unshift(@dir) # WARNING: MUST MATCH THE AFTER ACTIONS! + end + it 'should be able to find commands from both paths' do + found = @command_line.available_subcommands + found.should include 'foo' + @core_apps.each { |cmd| found.should include cmd } + end + after do + $LOAD_PATH.shift # WARNING: MUST MATCH THE BEFORE ACTIONS! + end + end + end end diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb index 04713f293..8545def54 100755 --- a/spec/unit/util/rdoc/parser_spec.rb +++ b/spec/unit/util/rdoc/parser_spec.rb @@ -45,6 +45,18 @@ describe RDoc::Parser do @parser.scan.should be_a(RDoc::PuppetTopLevel) end + + it "should scan the top level even if the file has already parsed" do + known_type = stub 'known_types' + env = stub 'env' + Puppet::Node::Environment.stubs(:new).returns(env) + env.stubs(:known_resource_types).returns(known_type) + known_type.expects(:watching_file?).with("module/manifests/init.pp").returns(true) + + @parser.expects(:scan_top_level) + + @parser.scan + end end describe "when scanning top level entities" do @@ -341,7 +353,7 @@ describe RDoc::Parser do describe "when scanning for includes and requires" do def create_stmt(name) - stmt_value = stub "#{name}_value", :value => "myclass" + stmt_value = stub "#{name}_value", :to_s => "myclass" Puppet::Parser::AST::Function.new( :name => name, @@ -359,13 +371,13 @@ describe RDoc::Parser do it "should also scan mono-instruction code" do @class.expects(:add_include).with { |i| i.is_a?(RDoc::Include) and i.name == "myclass" and i.comment == "mydoc" } - @parser.scan_for_include_or_require(@class,create_stmt("include")) + @parser.scan_for_include_or_require(@class, create_stmt("include")) end it "should register recursively includes to the current container" do @code.stubs(:children).returns([ create_stmt("include") ]) - @class.expects(:add_include).with { |i| i.is_a?(RDoc::Include) and i.name == "myclass" and i.comment == "mydoc" } + @class.expects(:add_include)#.with { |i| i.is_a?(RDoc::Include) and i.name == "myclass" and i.comment == "mydoc" } @parser.scan_for_include_or_require(@class, [@code]) end |