Sha256: 2fe392992dc6d4e80cdcd935dd1bca1d905fdca0ae63cbc3052fc55ffeb60d2b

Contents?: true

Size: 1.75 KB

Versions: 19

Compression:

Stored size: 1.75 KB

Contents

#!/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/resource/type_collection'
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

  def get_test_class(toplevel)
    # toplevel -> main -> test
    toplevel.classes[0].classes[0]
  end

  it "should parse to RDoc data structure" do
    @parser.expects(:document_class).with { |n,k,c| n == "::test" and k.is_a?(Puppet::Resource::Type) }
    @parser.scan
  end

  it "should get a PuppetClass for the main class" do
    @parser.scan.classes[0].should be_a(RDoc::PuppetClass)
  end

  it "should produce a PuppetClass whose name is test" do
    get_test_class(@parser.scan).name.should == "test"
  end

  it "should produce a PuppetClass whose comment is 'comment'" do
    get_test_class(@parser.scan).comment.should == "comment\n"
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.17 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.16 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.15 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.14 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.13 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.12 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.11 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.10 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.9 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.8 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.7 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.6 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.5 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.4 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.3 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.2 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.1 spec/integration/util/rdoc/parser_spec.rb
puppet-2.6.0 spec/integration/util/rdoc/parser_spec.rb