Merge pull request #13 from hkenney/issue/master/pdoc9_add-full-system-test
(PDOC-9) Add full system test
This commit is contained in:
commit
67c42a2f49
|
@ -20,3 +20,6 @@ Gemfile.lock
|
||||||
|
|
||||||
## YARD
|
## YARD
|
||||||
.yardoc
|
.yardoc
|
||||||
|
|
||||||
|
## MODULE BUILDS
|
||||||
|
**/pkg
|
||||||
|
|
4
Gemfile
4
Gemfile
|
@ -3,6 +3,7 @@ source 'https://rubygems.org'
|
||||||
gem 'yard'
|
gem 'yard'
|
||||||
gem 'rgen'
|
gem 'rgen'
|
||||||
gem 'redcarpet'
|
gem 'redcarpet'
|
||||||
|
gem 'puppet-strings', '0.1.0', :path => '.'
|
||||||
|
|
||||||
if puppetversion = ENV['PUPPET_VERSION']
|
if puppetversion = ENV['PUPPET_VERSION']
|
||||||
gem 'puppet', puppetversion
|
gem 'puppet', puppetversion
|
||||||
|
@ -15,6 +16,9 @@ group :test do
|
||||||
gem 'mocha'
|
gem 'mocha'
|
||||||
gem 'puppetlabs_spec_helper'
|
gem 'puppetlabs_spec_helper'
|
||||||
gem 'rspec-html-matchers'
|
gem 'rspec-html-matchers'
|
||||||
|
gem 'serverspec'
|
||||||
|
gem 'beaker'
|
||||||
|
gem 'beaker-rspec'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
|
6
Rakefile
6
Rakefile
|
@ -16,3 +16,9 @@ task :validate do
|
||||||
sh "erb -P -x -T '-' #{template} | ruby -c"
|
sh "erb -P -x -T '-' #{template} | ruby -c"
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
|
@ -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/
|
|
@ -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
|
|
@ -16,17 +16,17 @@ module StringsSpec
|
||||||
# Registry is what we expect when testing handlers
|
# Registry is what we expect when testing handlers
|
||||||
RSpec::Matchers.define :document_a do |arguments|
|
RSpec::Matchers.define :document_a do |arguments|
|
||||||
match do |actual|
|
match do |actual|
|
||||||
compare_values(actual).empty?
|
@mismatches = compare_values(actual, arguments)
|
||||||
|
@mismatches.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
failure_message do |actual|
|
failure_message_for_should do
|
||||||
mismatches = compare_values(actual)
|
@mismatches.collect do |key, value|
|
||||||
mismatches.collect do |key, value|
|
|
||||||
"Expected #{key} to be <#{value[1]}>, but got <#{value[0]}>."
|
"Expected #{key} to be <#{value[1]}>, but got <#{value[0]}>."
|
||||||
end.join("\n")
|
end.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def compare_values(actual)
|
def compare_values(actual, expected)
|
||||||
mismatched_arguments = {}
|
mismatched_arguments = {}
|
||||||
expected.each do |key, value|
|
expected.each do |key, value|
|
||||||
actual_value = actual.send(key)
|
actual_value = actual.send(key)
|
||||||
|
|
|
@ -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
|
|
@ -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'
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "username-test",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"author": "username",
|
||||||
|
"license": "Apache 2.0"
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ describe Puppet::Face do
|
||||||
|
|
||||||
Puppet::Face[:strings, :current].yardoc
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue