(PDOC-5) Test host classes and 3x functions
Add tests for the remaining two Puppet-specific handlers that were not tested in the previous commit. Specifically, add tests for the 3.x function handler and the host class handler.
This commit is contained in:
parent
8549bf7eff
commit
b2267fcfc6
|
@ -13,7 +13,7 @@ RSpec.configure do |config|
|
|||
config.mock_with :mocha
|
||||
end
|
||||
|
||||
# Borrwed from YARD spec helper
|
||||
# Borrowed from YARD spec helper
|
||||
def parse_file(file, thisfile = __FILE__, log_level = log.level, ext = '.pp')
|
||||
Registry.clear
|
||||
path = File.join(File.dirname(thisfile), 'examples', file.to_s + ext)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
name 'username-test'
|
||||
version '0.1.0'
|
||||
source ''
|
||||
author 'username'
|
||||
license 'Apache 2.0'
|
||||
summary ''
|
||||
description ''
|
||||
project_page ''
|
||||
|
||||
dependency 'puppetlabs/stdlib'
|
|
@ -0,0 +1,12 @@
|
|||
class test (
|
||||
$package_name = $test::params::package_name,
|
||||
$service_name = $test::params::service_name,
|
||||
) inherits test::params {
|
||||
|
||||
# validate parameters here
|
||||
|
||||
class { 'test::install': } ->
|
||||
class { 'test::config': } ~>
|
||||
class { 'test::service': } ->
|
||||
Class['test']
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
class foo::bar {
|
||||
file { '/test/file/path':
|
||||
owner => 'baz',
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
require 'puppet'
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:puppet3_function, :type => rvalue) do |args|
|
||||
puts 'Hello World!'
|
||||
end
|
||||
end
|
|
@ -4,9 +4,7 @@ require 'puppetx/yardoc/yard/handlers'
|
|||
describe Puppetx::Yardoc::YARD::Handlers do
|
||||
describe "DefinedTypeHanlder" do
|
||||
it "should add a defined type object in the Registry" do
|
||||
parse_file :defined_type, __FILE__
|
||||
require 'pry'
|
||||
#binding.pry
|
||||
parse_file :defined_type, __FILE__, log.level, '.pp'
|
||||
obj = Registry.at("wibbly::wobbly")
|
||||
expect(obj.type).to be(:definedtype)
|
||||
end
|
||||
|
@ -30,4 +28,31 @@ describe Puppetx::Yardoc::YARD::Handlers do
|
|||
expect(method.type).to be(:method)
|
||||
end
|
||||
end
|
||||
|
||||
describe "ParserFunctionHanlder" do
|
||||
before(:each) {parse_file :puppet3_function, __FILE__, log.level, '.rb'}
|
||||
|
||||
it "should add a module object to the Registry" do
|
||||
puppet_module = Registry.at("Puppet::Parser::Functions")
|
||||
expect(puppet_module.type).to be(:module)
|
||||
end
|
||||
|
||||
it "should add a puppet namespace object to the Registry" do
|
||||
namespace = Registry.at("ParserFunctions")
|
||||
expect(namespace.type).to be(:puppetnamespace)
|
||||
end
|
||||
|
||||
it "should add a method object to the Registry" do
|
||||
method = Registry.at("ParserFunctions#puppet3_function")
|
||||
expect(method.type).to be(:method)
|
||||
end
|
||||
end
|
||||
|
||||
describe "HostClassDefintion" do
|
||||
before(:each) {parse_file :class, __FILE__, log.level, '.pp'}
|
||||
it "should add a host class object to the Registry" do
|
||||
hostclass = Registry.at("foo::bar")
|
||||
expect(hostclass.type).to be(:hostclass)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue