(PDOC-25) Add tests to ensure namespaces are correct

Prior to this commit, there were no tests to check if namespaces
were being properly generated (which was why we did not catch the
bug earlier). Add a test for defined type and host class handlers
to ensure that namespaces are properly generated in code objects.
This commit is contained in:
Hailee Kenney 2015-03-13 10:48:29 -07:00
parent 685ebf54eb
commit 862b090221
2 changed files with 26 additions and 0 deletions

View File

@ -58,4 +58,17 @@ describe PuppetX::PuppetLabs::Strings::YARD::Handlers::DefinedTypeHandler do
expect(YARD::Registry.all).to be_empty
end
it "should generate the correct namespace " do
puppet_code = <<-PUPPET
define puppet_enterprise::mcollective::client::certs { }
PUPPET
parse(puppet_code, :puppet)
# If the namespace is not correctly generated, we will not be able to find the
# object via this name, meaning namespace will be nil
namespace = YARD::Registry.at("puppet_enterprise::mcollective::client::certs").namespace.to_s
expect(namespace).to_not be_nil
end
end

View File

@ -46,4 +46,17 @@ describe PuppetX::PuppetLabs::Strings::YARD::Handlers::HostClassHandler do
expect(the_hostclass).to document_a(:type => :hostclass, :docstring => "")
end
it "should generate the correct namespace " do
puppet_code = <<-PUPPET
class puppet_enterprise::mcollective::client::certs { }
PUPPET
parse(puppet_code, :puppet)
# If the namespace is not correctly generated, we will not be able to find the
# object via this name, meaning namespace will be nil
namespace = YARD::Registry.at("puppet_enterprise::mcollective::client::certs")
expect(namespace).to_not be_nil
end
end