diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-10-13 23:31:54 +0200 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-10-24 08:36:58 +1100 |
commit | b1deb89bae67f7d71ffe412ce4fd8e99c6e1c159 (patch) | |
tree | 8f464dc3828e6499b17f3fc228b578b6297b6a8b /spec/integration/util/rdoc/parser.rb | |
parent | ced5a7887836d1491273b5d6728589f494f8a337 (diff) | |
download | puppet-b1deb89bae67f7d71ffe412ce4fd8e99c6e1c159.tar.gz puppet-b1deb89bae67f7d71ffe412ce4fd8e99c6e1c159.tar.xz puppet-b1deb89bae67f7d71ffe412ce4fd8e99c6e1c159.zip |
Covers the RDoc Puppet Parser with specs
This doesn't cover all the code, only the part that interacts with
Puppet internals which is what matters when Puppet changes.
This patch also contains an integration test.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/integration/util/rdoc/parser.rb')
-rwxr-xr-x | spec/integration/util/rdoc/parser.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/integration/util/rdoc/parser.rb b/spec/integration/util/rdoc/parser.rb new file mode 100755 index 000000000..df8c62df6 --- /dev/null +++ b/spec/integration/util/rdoc/parser.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby + +Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } + +require 'puppet/parser/loaded_code' +require 'puppet/util/rdoc/parser' +require 'puppet/util/rdoc' +require 'puppet/util/rdoc/code_objects' +require 'rdoc/options' +require 'rdoc/rdoc' + +describe RDoc::Parser do + require 'puppet_spec/files' + include PuppetSpec::Files + + before :each do + tmpdir = tmpfile('rdoc_parser_tmp') + Dir.mkdir(tmpdir) + @parsedfile = File.join(tmpdir, 'init.pp') + + File.open(@parsedfile, 'w') do |f| + f.puts '# comment' + f.puts 'class ::test {}' + end + + @top_level = stub_everything 'toplevel', :file_relative_name => @parsedfile + @module = stub_everything 'module' + @puppet_top_level = RDoc::PuppetTopLevel.new(@top_level) + RDoc::PuppetTopLevel.stubs(:new).returns(@puppet_top_level) + @puppet_top_level.expects(:add_module).returns(@module) + @parser = RDoc::Parser.new(@top_level, @parsedfile, nil, Options.instance, RDoc::Stats.new) + end + + after(:each) do + File.unlink(@parsedfile) + end + + it "should parse to RDoc data structure" do + @parser.expects(:document_class).with { |n,k,c| n == "::test" and k.is_a?(Puppet::Parser::AST::HostClass) } + @parser.scan + end +end
\ No newline at end of file |