]> review.fuel-infra Code Review - puppet-modules/puppet-ceilometer.git/commitdiff
Add rspec-puppet-facts to the spec_helper
authorAlex Schultz <aschultz@mirantis.com>
Thu, 7 Jan 2016 04:28:00 +0000 (21:28 -0700)
committerDenis Egorenko <degorenko@mirantis.com>
Thu, 14 Jan 2016 17:32:37 +0000 (20:32 +0300)
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: Ie420cd2599fa3e88e6471bf3e9fce20d48f19805

Gemfile
spec/spec_helper.rb

diff --git a/Gemfile b/Gemfile
index fc22143982eeb61f0b2552d71d47045134f3e296..5ad0760ce657c30967ef8d5659136e8c187ae708 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
 group :development, :test do
   gem 'puppetlabs_spec_helper',               :require => 'false'
   gem 'rspec-puppet', '~> 2.2.0',             :require => 'false'
+  gem 'rspec-puppet-facts',                   :require => 'false'
   gem 'metadata-json-lint',                   :require => 'false'
   gem 'puppet-lint-param-docs',               :require => 'false'
   gem 'puppet-lint-absolute_classname-check', :require => 'false'
@@ -14,6 +15,9 @@ group :development, :test do
   gem 'puppet-lint-numericvariable',          :require => 'false'
   gem 'json',                                 :require => 'false'
   gem 'webmock',                              :require => 'false'
+  gem 'puppet-openstack_spec_helper',
+      :git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper',
+      :require => false
 end
 
 group :system_tests do
index 9bc7bcf96e09043ea23b5625ad9f25fba019f331..bd97904b9c66f14c1f5de98e63396cb25dd356f4 100644 (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