2018-01-26 14:05:22 +00:00
|
|
|
if ENV['COVERAGE'] == 'yes'
|
|
|
|
require 'simplecov'
|
|
|
|
require 'simplecov-console'
|
|
|
|
require 'codecov'
|
|
|
|
|
|
|
|
SimpleCov.formatters = [
|
|
|
|
SimpleCov::Formatter::HTMLFormatter,
|
|
|
|
SimpleCov::Formatter::Console,
|
|
|
|
SimpleCov::Formatter::Codecov,
|
|
|
|
]
|
|
|
|
SimpleCov.start do
|
|
|
|
track_files 'lib/**/*.rb'
|
|
|
|
|
|
|
|
add_filter '/spec'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-16 04:08:35 +00:00
|
|
|
require 'mocha'
|
|
|
|
require 'rspec'
|
2016-09-16 19:15:26 +00:00
|
|
|
require 'puppet/version'
|
2016-09-09 20:44:05 +00:00
|
|
|
require 'puppet-strings'
|
2018-01-23 00:22:42 +00:00
|
|
|
require 'puppet-strings/markdown'
|
|
|
|
require 'puppet-strings/markdown/base'
|
2016-09-14 19:20:26 +00:00
|
|
|
require 'puppet-strings/yard'
|
|
|
|
|
|
|
|
# Explicitly set up YARD once
|
|
|
|
PuppetStrings::Yard.setup!
|
2014-08-26 23:57:55 +00:00
|
|
|
|
2016-09-16 19:15:26 +00:00
|
|
|
# Enable testing of Puppet functions if running against 4.1+
|
(PDOC-228) puppet plans support
Currently, Puppet Strings only supports Puppet Tasks. Since Plans are
sort of connected to Tasks, it seemed right that Strings should also
support Plans. That and Plans are a thing that needs to be documented.
First, the Puppet[:tasks] setting needs to be set to add the 'plan' keyword to the Puppet Parser's lexicon, so this sets it in the Strings parser if the setting exists. If it does not exist and Puppet.version is less than 5.0.0, Strings will error out.
Second, processing for the Plans themselves is set up. Plans are very
similar to other Puppet objects like defined types and classes, so this
involved some serious copy-pasta.
Third, all the template/to_hash scaffolding for the different outputs is in place (HTML,
JSON, Markdown).
Yey.
2018-03-03 00:15:09 +00:00
|
|
|
TEST_PUPPET_FUNCTIONS = Puppet::Util::Package.versioncmp(Puppet.version, "4.1.0") >= 0
|
2016-09-16 19:15:26 +00:00
|
|
|
|
2016-11-11 20:33:02 +00:00
|
|
|
# Enable testing of Puppet language functions declared with return type if running against 4.8+
|
(PDOC-228) puppet plans support
Currently, Puppet Strings only supports Puppet Tasks. Since Plans are
sort of connected to Tasks, it seemed right that Strings should also
support Plans. That and Plans are a thing that needs to be documented.
First, the Puppet[:tasks] setting needs to be set to add the 'plan' keyword to the Puppet Parser's lexicon, so this sets it in the Strings parser if the setting exists. If it does not exist and Puppet.version is less than 5.0.0, Strings will error out.
Second, processing for the Plans themselves is set up. Plans are very
similar to other Puppet objects like defined types and classes, so this
involved some serious copy-pasta.
Third, all the template/to_hash scaffolding for the different outputs is in place (HTML,
JSON, Markdown).
Yey.
2018-03-03 00:15:09 +00:00
|
|
|
TEST_FUNCTION_RETURN_TYPE = Puppet::Util::Package.versioncmp(Puppet.version, "4.8.0") >= 0
|
|
|
|
|
|
|
|
# Enable testing of Plans if Puppet version is greater than 5.0.0
|
|
|
|
TEST_PUPPET_PLANS = Puppet::Util::Package.versioncmp(Puppet.version, "5.0.0") >= 0
|
2016-11-11 20:33:02 +00:00
|
|
|
|
2014-08-19 17:44:40 +00:00
|
|
|
RSpec.configure do |config|
|
2016-09-14 19:20:26 +00:00
|
|
|
config.mock_with :mocha
|
|
|
|
|
|
|
|
config.before(:each) do
|
|
|
|
# Always clear the YARD registry before each example
|
|
|
|
YARD::Registry.clear
|
|
|
|
end
|
2014-05-16 04:08:35 +00:00
|
|
|
end
|