Add rspec-puppet-facts to the spec_helper

This change adds the rspec-puppet-facts gem to the spec helper so that
we can centralize the management of the base operating systems that we
support. rspec-puppet-facts allows us to simplify our unit tests and
provides a more complete list of Operating Systems and their associated
facts for the unit tests.  With this change we can now loop over and
test CentOS, Debian, Fedora, RedHat, and Ubuntu by simply providing a
list of supported os to rspec-puppet-facts.

Additionally this change includes a central object for managing our
supported os list for rspec-puppet-facts and providing our default facts
like os_service_default. This central object should replace the usage of
@default_facts within the unit tests for each module.

Change-Id: I561ea844c05481a804975e77ff5f45002449f9a5
This commit is contained in:
Alex Schultz 2016-01-06 21:46:38 -07:00 committed by Denis Egorenko
parent eb8cb654ae
commit 1eed8eb9d3
2 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,7 @@ Gemfile:
- gem: puppetlabs_spec_helper
- gem: rspec-puppet
version: '~> 2.2.0'
- gem: rspec-puppet-facts
- gem: metadata-json-lint
- gem: puppet-lint-param-docs
- gem: puppet-lint-absolute_classname-check
@ -16,6 +17,8 @@ Gemfile:
- gem: puppet-lint-numericvariable
- gem: json
- gem: webmock
- gem: 'puppet-openstack_spec_helper'
git: 'https://git.openstack.org/openstack/puppet-openstack_spec_helper'
':system_tests':
- gem: beaker-rspec
- gem: beaker-puppet_install_helper

View File

@ -2,11 +2,17 @@ require 'puppetlabs_spec_helper/module_spec_helper'
require 'shared_examples'
require 'webmock/rspec'
require 'puppet-openstack_spec_helper/defaults'
require 'rspec-puppet-facts'
include RspecPuppetFacts
RSpec.configure do |c|
c.alias_it_should_behave_like_to :it_configures, 'configures'
c.alias_it_should_behave_like_to :it_raises, 'raises'
# TODO(aschultz): remove this after all tests converted to use OSDefaults
# instead of referencing @default_facts
c.before :each do
@default_facts = { :os_service_default => '<SERVICE DEFAULT>' }
@default_facts = OSDefaults.get_facts
end
end