Skip to content

Commit

Permalink
Merge pull request #505 from ekohl/fix-mock_with
Browse files Browse the repository at this point in the history
Various improvements to the spec_helper
  • Loading branch information
bastelfreak authored Oct 13, 2018
2 parents 272899e + 1376a64 commit 7536500
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
1 change: 1 addition & 0 deletions config_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Gemfile:
- gem: puppetlabs_spec_helper
version: '>= 2.11.0'
- gem: rspec-puppet-facts
version: '>= 1.8.0'
- gem: rspec-puppet-utils
- gem: puppet-lint-leading_zero-check
- gem: puppet-lint-trailing_comma-check
Expand Down
4 changes: 0 additions & 4 deletions moduleroot/spec/classes/coverage_spec.rb.erb

This file was deleted.

1 change: 0 additions & 1 deletion moduleroot/spec/default_facts.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Hint if using with rspec-puppet-facts ("on_supported_os.each"):
# if a same named fact exists in facterdb it will be overridden.
---
concat_basedir: "/tmp"
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
29 changes: 16 additions & 13 deletions moduleroot/spec/spec_helper.rb.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts

# This file is managed via modulesync
# https://github.com/voxpupuli/modulesync
# https://github.com/voxpupuli/modulesync_config
<%- if @configs['mock_with'] -%>
RSpec.configure do |c|
c.mock_with <%= @configs['mock_with'] %>
end

<%- end -%>
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts

<% if @configs['augeasproviders'] -%>
# Setup augeasproviders
Expand Down Expand Up @@ -37,22 +42,20 @@ if Dir.exist?(File.expand_path('../../lib', __FILE__))
end

RSpec.configure do |c|
default_facts = {
puppetversion: Puppet.version,
facterversion: Facter.version
}
default_facts = {}
default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__))
default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__))
c.default_facts = default_facts
<%- if @configs['mock_with'] -%>
c.mock_with <%= @configs['mock_with'] %>
<%- end -%>
<%- if @configs['hiera_config'] -%>
c.hiera_config = <%= @configs['hiera_config'] %>
<%- end -%>
end

# Coverage generation
c.after(:suite) do
RSpec::Puppet::Coverage.report!
end
end
<%- [@configs['spec_overrides']].flatten.compact.each do |line| -%>

<%= line %>
<%- end -%>
# vim: syntax=ruby

0 comments on commit 7536500

Please sign in to comment.