From 862b090221f3e09c6af48973c6d2676ddbca5841 Mon Sep 17 00:00:00 2001 From: Hailee Kenney Date: Fri, 13 Mar 2015 10:48:29 -0700 Subject: [PATCH] (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. --- .../strings/yard/defined_type_handler_spec.rb | 13 +++++++++++++ .../strings/yard/host_class_handler_spec.rb | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/spec/unit/puppet_x/puppetlabs/strings/yard/defined_type_handler_spec.rb b/spec/unit/puppet_x/puppetlabs/strings/yard/defined_type_handler_spec.rb index 7d684da..542393c 100644 --- a/spec/unit/puppet_x/puppetlabs/strings/yard/defined_type_handler_spec.rb +++ b/spec/unit/puppet_x/puppetlabs/strings/yard/defined_type_handler_spec.rb @@ -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 diff --git a/spec/unit/puppet_x/puppetlabs/strings/yard/host_class_handler_spec.rb b/spec/unit/puppet_x/puppetlabs/strings/yard/host_class_handler_spec.rb index 638eaaa..d926672 100644 --- a/spec/unit/puppet_x/puppetlabs/strings/yard/host_class_handler_spec.rb +++ b/spec/unit/puppet_x/puppetlabs/strings/yard/host_class_handler_spec.rb @@ -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