(PDOC-9) Add preliminary full system test
In order to help ensure that the strings module is not broken during development, add a full system integration test which can run at regular intervals to ensure that the module is working as expected. The test installs the string module as well as a test module which contains the different types of puppet and ruby code that the strings module can document. It then runs strings and ensures that the HTML generated is correct. Additionally, make some changes to the Gemfile to allow strings to be run as a gem even if it isn't installed in the modulepath. Also make a few changes to the unit tests to make them compatible with the version of rspec required by Beaker.
This commit is contained in:
parent
b07fc4a661
commit
ee6997cd24
|
@ -20,3 +20,6 @@ Gemfile.lock
|
|||
|
||||
## YARD
|
||||
.yardoc
|
||||
|
||||
## MODULE BUILDS
|
||||
**/pkg
|
||||
|
|
4
Gemfile
4
Gemfile
|
@ -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
|
||||
|
|
6
Rakefile
6
Rakefile
|
@ -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 "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,31 @@
|
|||
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
|
||||
on master, 'cat /root/doc/Puppet3xFunctions.html' do
|
||||
expect(read_file_on(master, '/root/doc/Puppet3xFunctions.html')).to have_tag('.docstring .discussion', :text => /documentation for `function3x`/)
|
||||
end
|
||||
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
|
||||
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)
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue