Merge pull request #13 from hkenney/issue/master/pdoc9_add-full-system-test

(PDOC-9) Add full system test
This commit is contained in:
Andrew Parker 2014-10-06 15:29:49 -07:00
commit 67c42a2f49
10 changed files with 96 additions and 16 deletions

3
.gitignore vendored
View File

@ -20,3 +20,6 @@ Gemfile.lock
## YARD
.yardoc
## MODULE BUILDS
**/pkg

View File

@ -3,6 +3,7 @@ source 'https://rubygems.org'
gem 'yard'
gem 'rgen'
gem 'redcarpet'
gem 'puppet-strings', '0.1.0', :path => '.'
if puppetversion = ENV['PUPPET_VERSION']
gem 'puppet', puppetversion
@ -15,6 +16,9 @@ group :test do
gem 'mocha'
gem 'puppetlabs_spec_helper'
gem 'rspec-html-matchers'
gem 'serverspec'
gem 'beaker'
gem 'beaker-rspec'
end
group :development do

View File

@ -16,3 +16,9 @@ task :validate do
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
task :acceptance do
sh "puppet module build"
sh "puppet module build spec/unit/puppet/examples/test"
sh "BEAKER_set=#{ENV["platform"]} rspec spec/acceptance/*.rb"
end

View File

@ -0,0 +1,13 @@
HOSTS:
master:
roles:
- master
platform: fedora-20-x86_64
hypervisor: vcloud
template: Delivery/Quality Assurance/Templates/vCloud/fedora-20-x86_64
CONFIG:
filecount: 12
datastore: instance0
resourcepool: delivery/Quality Assurance/FOSS/Dynamic
folder: Delivery/Quality Assurance/FOSS/Dynamic
pooling_api: http://vcloud.delivery.puppetlabs.net/

View File

@ -0,0 +1,29 @@
require 'spec_helper_acceptance'
require 'rspec-html-matchers'
require 'json'
describe 'Genearting module documation using yardoc action' do
def read_file_on(host, filename)
on(host, "cat #{filename}").stdout
end
before :all do
modules = JSON.parse(on(master, puppet("module", "list", "--render-as", "json")).stdout)
test_module_info = modules["modules_by_path"].values.flatten.find { |mod_info| mod_info =~ /Module test/ }
test_module_path = test_module_info.match(/\(([^)]*)\)/)[1]
on master, puppet("strings", "#{test_module_path}/**/*.{rb,pp}")
end
it "should generate documentation for manifests" do
expect(read_file_on(master, '/root/doc/test.html')).to have_tag('.docstring .discussion', :text => /This class/)
end
it "should generate documenation for 3x functions" do
expect(read_file_on(master, '/root/doc/Puppet3xFunctions.html')).to have_tag('.docstring .discussion', :text => /documentation for `function3x`/)
end
it "should generate documenation for 4x functions" do
expect(read_file_on(master, '/root/doc/Puppet4xFunctions.html')).to have_tag('.docstring .discussion', :text => /This is a function/)
end
end

View File

@ -16,17 +16,17 @@ module StringsSpec
# Registry is what we expect when testing handlers
RSpec::Matchers.define :document_a do |arguments|
match do |actual|
compare_values(actual).empty?
@mismatches = compare_values(actual, arguments)
@mismatches.empty?
end
failure_message do |actual|
mismatches = compare_values(actual)
mismatches.collect do |key, value|
failure_message_for_should do
@mismatches.collect do |key, value|
"Expected #{key} to be <#{value[1]}>, but got <#{value[0]}>."
end.join("\n")
end
def compare_values(actual)
def compare_values(actual, expected)
mismatched_arguments = {}
expected.each do |key, value|
actual_value = actual.send(key)

View File

@ -0,0 +1,29 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
unless ENV['RS_PROVISION'] == 'no'
install_puppet
end
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
hosts.each do |host|
scp_to(host, Dir.glob('pkg/puppetlabs-strings*.gz').first, 'strings.tar.gz')
on host, puppet('module', 'install', 'strings.tar.gz')
scp_to(host, Dir.glob('spec/unit/puppet/examples/test/pkg/username-test*.gz').first, 'test.tar.gz')
on host, puppet('module', 'install', 'test.tar.gz')
on host, 'gem install yard'
on host, 'gem install rgen'
end
end
end

View File

@ -1,10 +0,0 @@
name 'username-test'
version '0.1.0'
source ''
author 'username'
license 'Apache 2.0'
summary ''
description ''
project_page ''
dependency 'puppetlabs/stdlib'

View File

@ -0,0 +1,6 @@
{
"name": "username-test",
"version": "0.0.1",
"author": "username",
"license": "Apache 2.0"
}

View File

@ -61,7 +61,7 @@ describe Puppet::Face do
Puppet::Face[:strings, :current].yardoc
expect(read_html(tmp, 'test', 'test.html')).to have_tag('.docstring .discussion', :text => /This class/)
expect(read_html(tmp, 'test', 'Puppet4xFunctions.html')).to have_tag('.docstring .discussion', :text => /This is a function/)
end
end
end