Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to stringified facts; use rspec-puppet-facts 3 #134

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source 'https://rubygems.org'

gem 'rspec-puppet-facts', git: 'https://github.com/bastelfreak/rspec-puppet-facts', branch: 'foobaz'

gemspec

group :release do
Expand Down
2 changes: 2 additions & 0 deletions lib/voxpupuli/test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# and 7.12+ and requires rspec-puppet 2.11.0+.
config.facter_implementation = 'rspec'

config.facterdb_string_keys = true

config.after(:suite) do
RSpec::Puppet::Coverage.report!
end
Expand Down
25 changes: 12 additions & 13 deletions spec/facts_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'spec_helper'
require 'voxpupuli/test/facts'

describe 'override_facts' do
let(:base_facts) do
{
os: {
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
Expand All @@ -19,7 +18,7 @@
describe 'no overrides' do
let(:expected) do
{
os: {
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
Expand All @@ -37,7 +36,7 @@
describe 'with addition at the top level' do
let(:expected) do
{
os: {
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
Expand All @@ -46,19 +45,19 @@
'minor' => '7'
},
},
ruby: {
'ruby' => {
'sitedir' => '/usr/local/share/ruby/site_ruby',
}
}
end

it { expect(override_facts(base_facts, ruby: {sitedir: '/usr/local/share/ruby/site_ruby'})).to eq(expected) }
it { expect(override_facts(base_facts, 'ruby' => { 'sitedir' => '/usr/local/share/ruby/site_ruby'})).to eq(expected) }
end

describe 'with deep merging' do
let(:expected) do
{
os: {
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
Expand All @@ -70,13 +69,13 @@
}
end

it { expect(override_facts(base_facts, os: {release: {minor: '8'}})).to eq(expected) }
it { expect(override_facts(base_facts, 'os' => { 'release' => {'minor' => '8'}})).to eq(expected) }
end

describe 'with strings' do
let(:expected) do
{
os: {
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
Expand All @@ -88,7 +87,7 @@
}
end

it { expect(override_facts(base_facts, os: {'release' => {minor: '8'}})).to eq(expected) }
it { expect(override_facts(base_facts, 'os' => {'release' => {minor: '8'}})).to eq(expected) }
end
end

Expand Down Expand Up @@ -132,23 +131,23 @@
it 'has systemd on Red Hat 7' do
add_facts_for_metadata(metadata)
facts = RspecPuppetFacts.with_custom_facts('redhat-7-x86_64', {
os: { 'family' => 'RedHat', 'release' => { 'major' => '7' } }
'os' => { 'family' => 'RedHat', 'release' => { 'major' => '7' } }
})
expect(facts['systemd']).to be true
end

it 'has no systemd on Red Hat 6' do
add_facts_for_metadata(metadata)
facts = RspecPuppetFacts.with_custom_facts('redhat-6-x86_64', {
os: {'family' => 'RedHat', 'release' => { 'major' => '6' }}
'os' => {'family' => 'RedHat', 'release' => { 'major' => '6' }}
})
expect(facts['systemd']).to be false
end

it 'has no systemd on openbsd' do
add_facts_for_metadata(metadata)
facts = RspecPuppetFacts.with_custom_facts('openbsd-6.4-x86_64', {
os: { 'family' => 'OpenBSD' }
'os' => { 'family' => 'OpenBSD' }
})
expect(facts['systemd']).to be false
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
end

require 'rspec/core'
require 'voxpupuli/test/spec_helper'
2 changes: 1 addition & 1 deletion voxpupuli-test.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |s|
# 3.0.0 and later require Ruby 2.7
s.add_runtime_dependency 'puppet-strings', '~> 4.0'
s.add_runtime_dependency 'rspec-puppet', '~> 4.0'
s.add_runtime_dependency 'rspec-puppet-facts', '~> 2.0', '>= 2.0.5'
s.add_runtime_dependency 'rspec-puppet-facts', '~> 3.0'
s.add_runtime_dependency 'rspec-puppet-utils', '~> 3.4'

# Rubocop
Expand Down
Loading