From 12543eed1d36f109ded38285f8217aa69f2bfaa7 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Tue, 31 Dec 2024 11:55:54 -0600 Subject: [PATCH] Cleanup * (More) consistently use `.dig` to retrieve facts * Supply missing facts in tests --- lib/puppet/functions/simplib/host_is_me.rb | 4 +- lib/puppet/functions/simplib/ip_to_cron.rb | 2 +- .../functions/simplib/join_mount_opts.rb | 2 +- lib/puppet/provider/reboot_notify/notify.rb | 2 +- spec/classes/reboot_notify_spec.rb | 4 +- spec/functions/ldap/domain_to_dn_spec.rb | 42 ++++--- spec/functions/simplib/dlookup_spec.rb | 113 +++++++++--------- spec/type_aliases/cron/hour_entry_spec.rb | 56 +++++---- spec/type_aliases/cron/hour_spec.rb | 36 +++--- spec/type_aliases/cron/minute_entry_spec.rb | 56 +++++---- spec/type_aliases/cron/minute_spec.rb | 36 +++--- spec/type_aliases/cron/month_entry_spec.rb | 72 ++++++----- spec/type_aliases/cron/month_spec.rb | 42 ++++--- spec/type_aliases/cron/monthday_entry_spec.rb | 58 +++++---- spec/type_aliases/cron/monthday_spec.rb | 36 +++--- spec/type_aliases/cron/weekday_entry_spec.rb | 78 ++++++------ spec/type_aliases/cron/weekday_spec.rb | 40 ++++--- spec/type_aliases/domain_spec.rb | 94 ++++++++------- spec/type_aliases/domainlist_spec.rb | 22 ++-- spec/type_aliases/shadowpass_spec.rb | 38 +++--- spec/type_aliases/simplib_macaddress_spec.rb | 30 +++-- spec/unit/data_types/emailaddress_spec.rb | 63 +++++----- spec/unit/data_types/host/port_spec.rb | 59 ++++----- spec/unit/data_types/host_spec.rb | 57 +++++---- spec/unit/data_types/hostname/port_spec.rb | 57 +++++---- spec/unit/data_types/hostname_spec.rb | 57 +++++---- spec/unit/data_types/ip/v4/cidr_spec.rb | 57 +++++---- spec/unit/data_types/ip/v4/ddq_spec.rb | 57 +++++---- spec/unit/data_types/ip/v4/port_spec.rb | 57 +++++---- spec/unit/data_types/ip/v4_spec.rb | 57 +++++---- spec/unit/data_types/ip/v6/base_spec.rb | 57 +++++---- spec/unit/data_types/ip/v6/bracketed_spec.rb | 57 +++++---- spec/unit/data_types/ip/v6/cidr_spec.rb | 57 +++++---- spec/unit/data_types/ip/v6/port_spec.rb | 57 +++++---- spec/unit/data_types/ip/v6_spec.rb | 57 +++++---- spec/unit/data_types/ip_spec.rb | 57 +++++---- spec/unit/data_types/netlist/host_spec.rb | 57 +++++---- spec/unit/data_types/netlist/ip/v4_spec.rb | 57 +++++---- spec/unit/data_types/netlist/ip/v6_spec.rb | 57 +++++---- spec/unit/data_types/netlist/ip_spec.rb | 57 +++++---- spec/unit/data_types/netlist/port_spec.rb | 57 +++++---- spec/unit/data_types/netlist_spec.rb | 57 +++++---- spec/unit/data_types/port/dynamic_spec.rb | 49 ++++---- spec/unit/data_types/port/random_spec.rb | 49 ++++---- spec/unit/data_types/port/system_spec.rb | 49 ++++---- spec/unit/data_types/port/user_spec.rb | 49 ++++---- spec/unit/data_types/port_spec.rb | 49 ++++---- spec/unit/data_types/shadowpass_spec.rb | 25 ++-- spec/unit/data_types/syslog/cfacility_spec.rb | 61 +++++----- spec/unit/data_types/syslog/cpriority_spec.rb | 61 +++++----- spec/unit/data_types/syslog/cseverity_spec.rb | 61 +++++----- spec/unit/data_types/syslog/facility_spec.rb | 59 ++++----- .../data_types/syslog/lowerfacility_spec.rb | 59 ++++----- .../data_types/syslog/lowerpriority_spec.rb | 61 +++++----- .../data_types/syslog/lowerseverity_spec.rb | 59 ++++----- spec/unit/data_types/syslog/priority_spec.rb | 59 ++++----- spec/unit/data_types/syslog/severity_spec.rb | 59 ++++----- .../data_types/syslog/upperfacility_spec.rb | 59 ++++----- .../data_types/syslog/upperpriority_spec.rb | 59 ++++----- .../data_types/syslog/upperseverity_spec.rb | 59 ++++----- .../data_types/systemd/servicename_spec.rb | 57 +++++---- spec/unit/data_types/umask_spec.rb | 63 +++++----- spec/unit/data_types/uri_spec.rb | 67 ++++++----- 63 files changed, 1773 insertions(+), 1468 deletions(-) diff --git a/lib/puppet/functions/simplib/host_is_me.rb b/lib/puppet/functions/simplib/host_is_me.rb index 2867bd95..1481aae3 100644 --- a/lib/puppet/functions/simplib/host_is_me.rb +++ b/lib/puppet/functions/simplib/host_is_me.rb @@ -28,8 +28,8 @@ def hostlist_contains_me(hosts) scope = closure_scope host_identifiers = [ - scope['facts']['networking']['fqdn'], - scope['facts']['networking']['hostname'], + scope['facts'].dig('networking', 'fqdn'), + scope['facts'].dig('networking', 'hostname'), 'localhost', 'localhost.localdomain', ] diff --git a/lib/puppet/functions/simplib/ip_to_cron.rb b/lib/puppet/functions/simplib/ip_to_cron.rb index fa55083a..c986c93f 100644 --- a/lib/puppet/functions/simplib/ip_to_cron.rb +++ b/lib/puppet/functions/simplib/ip_to_cron.rb @@ -53,7 +53,7 @@ def ip_to_cron(occurs = 1, max_value = 59, algorithm = 'ip_mod', ip = nil) if ip.nil? scope = closure_scope - ipaddr = scope['facts']['networking']['ip'] + ipaddr = scope['facts'].dig('networking', 'ip') else ipaddr = ip.dup end diff --git a/lib/puppet/functions/simplib/join_mount_opts.rb b/lib/puppet/functions/simplib/join_mount_opts.rb index ee16fe3d..c03b7b2a 100644 --- a/lib/puppet/functions/simplib/join_mount_opts.rb +++ b/lib/puppet/functions/simplib/join_mount_opts.rb @@ -34,7 +34,7 @@ def join_mount_opts(system_mount_opts, new_mount_opts) mount_options = {} scope = closure_scope - selinux_current_mode = scope['facts']['os'].dig('selinux', 'current_mode') + selinux_current_mode = scope['facts'].dig('os', 'selinux', 'current_mode') if !selinux_current_mode || (selinux_current_mode == 'disabled') # SELinux is off, get rid of selinux related items in the options diff --git a/lib/puppet/provider/reboot_notify/notify.rb b/lib/puppet/provider/reboot_notify/notify.rb index 158a7ddc..3955ed1c 100644 --- a/lib/puppet/provider/reboot_notify/notify.rb +++ b/lib/puppet/provider/reboot_notify/notify.rb @@ -124,7 +124,7 @@ def self.post_resource_eval # If the number of seconds between the time that the record was written # and the current time is greater than the system uptime then we should # remove the record - (current_time - v['updated']) > Facter.value(:system_uptime)['seconds'] + (current_time - v['updated']) > Facter.value(:system_uptime)&.dig('seconds') end unless records.empty? diff --git a/spec/classes/reboot_notify_spec.rb b/spec/classes/reboot_notify_spec.rb index 6aca5fac..af8220f3 100644 --- a/spec/classes/reboot_notify_spec.rb +++ b/spec/classes/reboot_notify_spec.rb @@ -2,8 +2,10 @@ describe 'simplib::reboot_notify' do context 'on supported operating systems' do - on_supported_os.each_key do |os| + on_supported_os.each do |os, os_facts| context "on #{os}" do + let(:facts) { os_facts } + it { is_expected.to compile.with_all_deps } it { is_expected.to create_reboot_notify('__simplib_control__').with_log_level('notice') } it { is_expected.to create_reboot_notify('__simplib_control__').with_control_only(true) } diff --git a/spec/functions/ldap/domain_to_dn_spec.rb b/spec/functions/ldap/domain_to_dn_spec.rb index 6cb64eaa..de9e1495 100644 --- a/spec/functions/ldap/domain_to_dn_spec.rb +++ b/spec/functions/ldap/domain_to_dn_spec.rb @@ -1,31 +1,35 @@ require 'spec_helper' describe 'simplib::ldap::domain_to_dn' do - on_supported_os.each_value do |os_facts| - context 'with a regular domain' do - let(:facts) do - os_facts[:networking][:domain] = 'test.domain' - os_facts - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } - it { is_expected.to run.and_return('DC=test,DC=domain') } - end + context 'with a regular domain' do + let(:facts) do + os_facts[:networking][:domain] = 'test.domain' + os_facts + end - context 'with a short domain' do - let(:facts) do - os_facts[:networking][:domain] = 'domain' - os_facts + it { is_expected.to run.and_return('DC=test,DC=domain') } end - it { is_expected.to run.and_return('DC=domain') } - end + context 'with a short domain' do + let(:facts) do + os_facts[:networking][:domain] = 'domain' + os_facts + end - context 'when passed a domain' do - it { is_expected.to run.with_params('test.domain').and_return('DC=test,DC=domain') } - end + it { is_expected.to run.and_return('DC=domain') } + end + + context 'when passed a domain' do + it { is_expected.to run.with_params('test.domain').and_return('DC=test,DC=domain') } + end - context 'when told to downcase the attributes' do - it { is_expected.to run.with_params('test.domain', true).and_return('dc=test,dc=domain') } + context 'when told to downcase the attributes' do + it { is_expected.to run.with_params('test.domain', true).and_return('dc=test,dc=domain') } + end end end end diff --git a/spec/functions/simplib/dlookup_spec.rb b/spec/functions/simplib/dlookup_spec.rb index 6ec8a6e7..90c5d70e 100644 --- a/spec/functions/simplib/dlookup_spec.rb +++ b/spec/functions/simplib/dlookup_spec.rb @@ -2,70 +2,75 @@ # This just gives us a hook so that we can call the function later on describe 'simplib::stages', type: :class do - let(:pre_condition) do - <<~END - define mydef::test ( - $attribute = simplib::dlookup('mydef::test', 'attribute', $title, { 'default_value' => 'lucille2' }) - ) { - notify { "$title says": message => $attribute } - } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + define mydef::test ( + $attribute = simplib::dlookup('mydef::test', 'attribute', $title, { 'default_value' => 'lucille2' }) + ) { + notify { "$title says": message => $attribute } + } - define mydef::othertest ( - $attribute = simplib::dlookup('mydef::test', 'attribute', { 'default_value' => 'lucille2' }) - ) { - notify { "other $title says": message => $attribute } - } + define mydef::othertest ( + $attribute = simplib::dlookup('mydef::test', 'attribute', { 'default_value' => 'lucille2' }) + ) { + notify { "other $title says": message => $attribute } + } - mydef::test { 'gob': } - mydef::test { 'tobias': } - mydef::test { 'michael': attribute => 'bananastand' } + mydef::test { 'gob': } + mydef::test { 'tobias': } + mydef::test { 'michael': attribute => 'bananastand' } - mydef::othertest { 'gob': } - mydef::othertest { 'tobias': } - mydef::othertest { 'michael': attribute => 'bananastand' } - END - end + mydef::othertest { 'gob': } + mydef::othertest { 'tobias': } + mydef::othertest { 'michael': attribute => 'bananastand' } + END + end - let(:gob) { catalogue.resource('Mydef::Test[gob]') } - let(:tobias) { catalogue.resource('Mydef::Test[tobias]') } - let(:michael) { catalogue.resource('Mydef::Test[michael]') } + let(:gob) { catalogue.resource('Mydef::Test[gob]') } + let(:tobias) { catalogue.resource('Mydef::Test[tobias]') } + let(:michael) { catalogue.resource('Mydef::Test[michael]') } - let(:gob_other) { catalogue.resource('Mydef::Othertest[gob]') } - let(:tobias_other) { catalogue.resource('Mydef::Othertest[tobias]') } - let(:michael_other) { catalogue.resource('Mydef::Othertest[michael]') } + let(:gob_other) { catalogue.resource('Mydef::Othertest[gob]') } + let(:tobias_other) { catalogue.resource('Mydef::Othertest[tobias]') } + let(:michael_other) { catalogue.resource('Mydef::Othertest[michael]') } - it { is_expected.to compile.with_all_deps } + it { is_expected.to compile.with_all_deps } - context 'no overrides' do - it { expect(gob[:attribute]).to eq('lucille2') } - it { expect(tobias[:attribute]).to eq('lucille2') } - it { expect(michael[:attribute]).to eq('bananastand') } - it { expect(gob_other[:attribute]).to eq('lucille2') } - it { expect(tobias_other[:attribute]).to eq('lucille2') } - it { expect(michael_other[:attribute]).to eq('bananastand') } - end + context 'no overrides' do + it { expect(gob[:attribute]).to eq('lucille2') } + it { expect(tobias[:attribute]).to eq('lucille2') } + it { expect(michael[:attribute]).to eq('bananastand') } + it { expect(gob_other[:attribute]).to eq('lucille2') } + it { expect(tobias_other[:attribute]).to eq('lucille2') } + it { expect(michael_other[:attribute]).to eq('bananastand') } + end - context 'overrides' do - let(:facts) do - { - cache_bust: Time.now.to_s, - hieradata: 'simplib_dlookup_overrides', - } - end + context 'overrides' do + let(:facts) do + os_facts.merge( + cache_bust: Time.now.to_s, + hieradata: 'simplib_dlookup_overrides', + ) + end - let(:hieradata) { 'simplib_dlookup_overrides' } + let(:hieradata) { 'simplib_dlookup_overrides' } - context 'with global overrides' do - it { expect(gob[:attribute]).to eq('illusions') } - it { expect(gob_other[:attribute]).to eq('illusions') } - it { expect(tobias_other[:attribute]).to eq('illusions') } - end - context 'with specific overrides' do - it { expect(tobias[:attribute]).to eq('blueman') } - end - context 'with a static value' do - it { expect(michael[:attribute]).to eq('bananastand') } - it { expect(michael_other[:attribute]).to eq('bananastand') } + context 'with global overrides' do + it { expect(gob[:attribute]).to eq('illusions') } + it { expect(gob_other[:attribute]).to eq('illusions') } + it { expect(tobias_other[:attribute]).to eq('illusions') } + end + context 'with specific overrides' do + it { expect(tobias[:attribute]).to eq('blueman') } + end + context 'with a static value' do + it { expect(michael[:attribute]).to eq('bananastand') } + it { expect(michael_other[:attribute]).to eq('bananastand') } + end + end end end end diff --git a/spec/type_aliases/cron/hour_entry_spec.rb b/spec/type_aliases/cron/hour_entry_spec.rb index 6114ee1d..1cd0fd07 100644 --- a/spec/type_aliases/cron/hour_entry_spec.rb +++ b/spec/type_aliases/cron/hour_entry_spec.rb @@ -1,30 +1,36 @@ require 'spec_helper' describe 'Simplib::Cron::Hour_entry' do - context 'with valid parameters' do - it { is_expected.to allow_value('22') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('2/5') } - it { is_expected.to allow_value(22) } - it { is_expected.to allow_value('23,20') } - it { is_expected.to allow_value('20-23') } - it { is_expected.to allow_value('0-23/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value('one') } - it { is_expected.not_to allow_value('-2') } - it { is_expected.not_to allow_value('/3') } - it { is_expected.not_to allow_value('24') } - it { is_expected.not_to allow_value('13/*') } - it { is_expected.not_to allow_value('13-/15') } - end - context 'with silly things' do - it { is_expected.not_to allow_value([]) } - it { is_expected.not_to allow_value('.') } - it { is_expected.not_to allow_value('') } - it { is_expected.not_to allow_value('1 ') } - it { is_expected.not_to allow_value('5 1') } - it { is_expected.not_to allow_value(:undef) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value('22') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('2/5') } + it { is_expected.to allow_value(22) } + it { is_expected.to allow_value('23,20') } + it { is_expected.to allow_value('20-23') } + it { is_expected.to allow_value('0-23/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value('one') } + it { is_expected.not_to allow_value('-2') } + it { is_expected.not_to allow_value('/3') } + it { is_expected.not_to allow_value('24') } + it { is_expected.not_to allow_value('13/*') } + it { is_expected.not_to allow_value('13-/15') } + end + context 'with silly things' do + it { is_expected.not_to allow_value([]) } + it { is_expected.not_to allow_value('.') } + it { is_expected.not_to allow_value('') } + it { is_expected.not_to allow_value('1 ') } + it { is_expected.not_to allow_value('5 1') } + it { is_expected.not_to allow_value(:undef) } + end + end end end diff --git a/spec/type_aliases/cron/hour_spec.rb b/spec/type_aliases/cron/hour_spec.rb index c02c0e7e..6fde05b8 100644 --- a/spec/type_aliases/cron/hour_spec.rb +++ b/spec/type_aliases/cron/hour_spec.rb @@ -1,20 +1,26 @@ require 'spec_helper' describe 'Simplib::Cron::Hour' do - context 'with valid parameters' do - it { is_expected.to allow_value([22]) } - it { is_expected.to allow_value(['22']) } - it { is_expected.to allow_value(['20-23', '10-14/2', 3, 5, '19']) } - it { is_expected.to allow_value(22) } - it { is_expected.to allow_value('22') } - it { is_expected.to allow_value('20-23') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('0-23/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value(['20-23', '10-14/2', 3, 24, 5, '19']) } - it { is_expected.not_to allow_value(['0,1,12-19,5']) } - it { is_expected.not_to allow_value(["'0','1','12-19','5'"]) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value([22]) } + it { is_expected.to allow_value(['22']) } + it { is_expected.to allow_value(['20-23', '10-14/2', 3, 5, '19']) } + it { is_expected.to allow_value(22) } + it { is_expected.to allow_value('22') } + it { is_expected.to allow_value('20-23') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('0-23/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value(['20-23', '10-14/2', 3, 24, 5, '19']) } + it { is_expected.not_to allow_value(['0,1,12-19,5']) } + it { is_expected.not_to allow_value(["'0','1','12-19','5'"]) } + end + end end end diff --git a/spec/type_aliases/cron/minute_entry_spec.rb b/spec/type_aliases/cron/minute_entry_spec.rb index 96b4abf3..c5f2eca6 100644 --- a/spec/type_aliases/cron/minute_entry_spec.rb +++ b/spec/type_aliases/cron/minute_entry_spec.rb @@ -1,30 +1,36 @@ require 'spec_helper' describe 'Simplib::Cron::Minute_entry' do - context 'with valid parameters' do - it { is_expected.to allow_value('22') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('2/5') } - it { is_expected.to allow_value(22) } - it { is_expected.to allow_value('23,20') } - it { is_expected.to allow_value('20-23') } - it { is_expected.to allow_value('0-23/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value('one') } - it { is_expected.not_to allow_value('-2') } - it { is_expected.not_to allow_value('/3') } - it { is_expected.not_to allow_value('60') } - it { is_expected.not_to allow_value('13/*') } - it { is_expected.not_to allow_value('13-/15') } - end - context 'with silly things' do - it { is_expected.not_to allow_value([]) } - it { is_expected.not_to allow_value('.') } - it { is_expected.not_to allow_value('') } - it { is_expected.not_to allow_value('1 ') } - it { is_expected.not_to allow_value('5 1') } - it { is_expected.not_to allow_value(:undef) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value('22') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('2/5') } + it { is_expected.to allow_value(22) } + it { is_expected.to allow_value('23,20') } + it { is_expected.to allow_value('20-23') } + it { is_expected.to allow_value('0-23/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value('one') } + it { is_expected.not_to allow_value('-2') } + it { is_expected.not_to allow_value('/3') } + it { is_expected.not_to allow_value('60') } + it { is_expected.not_to allow_value('13/*') } + it { is_expected.not_to allow_value('13-/15') } + end + context 'with silly things' do + it { is_expected.not_to allow_value([]) } + it { is_expected.not_to allow_value('.') } + it { is_expected.not_to allow_value('') } + it { is_expected.not_to allow_value('1 ') } + it { is_expected.not_to allow_value('5 1') } + it { is_expected.not_to allow_value(:undef) } + end + end end end diff --git a/spec/type_aliases/cron/minute_spec.rb b/spec/type_aliases/cron/minute_spec.rb index e4effb63..f61a3379 100644 --- a/spec/type_aliases/cron/minute_spec.rb +++ b/spec/type_aliases/cron/minute_spec.rb @@ -1,20 +1,26 @@ require 'spec_helper' describe 'Simplib::Cron::Minute' do - context 'with valid parameters' do - it { is_expected.to allow_value([22]) } - it { is_expected.to allow_value(['22']) } - it { is_expected.to allow_value(['20-23', '10-14/2', 3, 5, '19']) } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value(22) } - it { is_expected.to allow_value('22') } - it { is_expected.to allow_value('20-23') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('0-23/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value(['20-23', '10-14/2', 3, 60, 5, '19']) } - it { is_expected.not_to allow_value(['0,1,12-19,5']) } - it { is_expected.not_to allow_value(["'0','1','12-19','5'"]) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value([22]) } + it { is_expected.to allow_value(['22']) } + it { is_expected.to allow_value(['20-23', '10-14/2', 3, 5, '19']) } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value(22) } + it { is_expected.to allow_value('22') } + it { is_expected.to allow_value('20-23') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('0-23/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value(['20-23', '10-14/2', 3, 60, 5, '19']) } + it { is_expected.not_to allow_value(['0,1,12-19,5']) } + it { is_expected.not_to allow_value(["'0','1','12-19','5'"]) } + end + end end end diff --git a/spec/type_aliases/cron/month_entry_spec.rb b/spec/type_aliases/cron/month_entry_spec.rb index 4377b839..1cf9ec64 100644 --- a/spec/type_aliases/cron/month_entry_spec.rb +++ b/spec/type_aliases/cron/month_entry_spec.rb @@ -1,38 +1,44 @@ require 'spec_helper' describe 'Simplib::Cron::Month_entry' do - context 'with valid parameters' do - it { is_expected.to allow_value('2') } - it { is_expected.to allow_value(2) } - it { is_expected.to allow_value('JAN') } - it { is_expected.to allow_value('jan') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('2-10') } - it { is_expected.to allow_value('2-10/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value('1,3-5') } - it { is_expected.not_to allow_value('JAN,MAR,JUN,APR') } - it { is_expected.not_to allow_value('APRIL') } - it { is_expected.not_to allow_value('APR-JUN') } - it { is_expected.not_to allow_value('-2') } - it { is_expected.not_to allow_value('/3') } - it { is_expected.not_to allow_value('1,FEB,3,5') } - it { is_expected.not_to allow_value('FEB-5') } - it { is_expected.not_to allow_value('FEB/3') } - it { is_expected.not_to allow_value('0') } - it { is_expected.not_to allow_value('13') } - it { is_expected.not_to allow_value('3/*') } - it { is_expected.not_to allow_value('2/10') } - it { is_expected.not_to allow_value('3-/5') } - end - context 'with silly things' do - it { is_expected.not_to allow_value([]) } - it { is_expected.not_to allow_value('.') } - it { is_expected.not_to allow_value('') } - it { is_expected.not_to allow_value('1 ') } - it { is_expected.not_to allow_value('5 1') } - it { is_expected.not_to allow_value(:undef) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value('2') } + it { is_expected.to allow_value(2) } + it { is_expected.to allow_value('JAN') } + it { is_expected.to allow_value('jan') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('2-10') } + it { is_expected.to allow_value('2-10/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value('1,3-5') } + it { is_expected.not_to allow_value('JAN,MAR,JUN,APR') } + it { is_expected.not_to allow_value('APRIL') } + it { is_expected.not_to allow_value('APR-JUN') } + it { is_expected.not_to allow_value('-2') } + it { is_expected.not_to allow_value('/3') } + it { is_expected.not_to allow_value('1,FEB,3,5') } + it { is_expected.not_to allow_value('FEB-5') } + it { is_expected.not_to allow_value('FEB/3') } + it { is_expected.not_to allow_value('0') } + it { is_expected.not_to allow_value('13') } + it { is_expected.not_to allow_value('3/*') } + it { is_expected.not_to allow_value('2/10') } + it { is_expected.not_to allow_value('3-/5') } + end + context 'with silly things' do + it { is_expected.not_to allow_value([]) } + it { is_expected.not_to allow_value('.') } + it { is_expected.not_to allow_value('') } + it { is_expected.not_to allow_value('1 ') } + it { is_expected.not_to allow_value('5 1') } + it { is_expected.not_to allow_value(:undef) } + end + end end end diff --git a/spec/type_aliases/cron/month_spec.rb b/spec/type_aliases/cron/month_spec.rb index 42e5b043..4331f1ea 100644 --- a/spec/type_aliases/cron/month_spec.rb +++ b/spec/type_aliases/cron/month_spec.rb @@ -1,23 +1,29 @@ require 'spec_helper' describe 'Simplib::Cron::Month' do - context 'with valid parameters' do - it { is_expected.to allow_value([12]) } - it { is_expected.to allow_value(['12']) } - it { is_expected.to allow_value(['dec']) } - it { is_expected.to allow_value(['DEC']) } - it { is_expected.to allow_value(['10-11', 'DEC', 'jan', '1-6/2', 3, 5, '9']) } - it { is_expected.to allow_value(12) } - it { is_expected.to allow_value('12') } - it { is_expected.to allow_value('DEC') } - it { is_expected.to allow_value('2-3') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('1-12/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value(['10-12', '1-6/2', 3, 0, 'MAY', '9']) } - it { is_expected.not_to allow_value(['0,1,11-12,5']) } - it { is_expected.not_to allow_value(["'3','1','10-12','5'"]) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value([12]) } + it { is_expected.to allow_value(['12']) } + it { is_expected.to allow_value(['dec']) } + it { is_expected.to allow_value(['DEC']) } + it { is_expected.to allow_value(['10-11', 'DEC', 'jan', '1-6/2', 3, 5, '9']) } + it { is_expected.to allow_value(12) } + it { is_expected.to allow_value('12') } + it { is_expected.to allow_value('DEC') } + it { is_expected.to allow_value('2-3') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('1-12/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value(['10-12', '1-6/2', 3, 0, 'MAY', '9']) } + it { is_expected.not_to allow_value(['0,1,11-12,5']) } + it { is_expected.not_to allow_value(["'3','1','10-12','5'"]) } + end + end end end diff --git a/spec/type_aliases/cron/monthday_entry_spec.rb b/spec/type_aliases/cron/monthday_entry_spec.rb index 0fee6e66..ebc6c66c 100644 --- a/spec/type_aliases/cron/monthday_entry_spec.rb +++ b/spec/type_aliases/cron/monthday_entry_spec.rb @@ -1,31 +1,37 @@ require 'spec_helper' describe 'Simplib::Cron::MonthDay_entry' do - context 'with valid parameters' do - it { is_expected.to allow_value('22') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value(22) } - it { is_expected.to allow_value('20-23') } - it { is_expected.to allow_value('1-23/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value('one') } - it { is_expected.not_to allow_value('-2') } - it { is_expected.not_to allow_value('/3') } - it { is_expected.not_to allow_value('32') } - it { is_expected.not_to allow_value(0) } - it { is_expected.not_to allow_value('23,20') } - it { is_expected.not_to allow_value('13/*') } - it { is_expected.not_to allow_value('2/5') } - it { is_expected.not_to allow_value('13-/15') } - end - context 'with silly things' do - it { is_expected.not_to allow_value([]) } - it { is_expected.not_to allow_value('.') } - it { is_expected.not_to allow_value('') } - it { is_expected.not_to allow_value('1 ') } - it { is_expected.not_to allow_value('5 1') } - it { is_expected.not_to allow_value(:undef) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value('22') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value(22) } + it { is_expected.to allow_value('20-23') } + it { is_expected.to allow_value('1-23/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value('one') } + it { is_expected.not_to allow_value('-2') } + it { is_expected.not_to allow_value('/3') } + it { is_expected.not_to allow_value('32') } + it { is_expected.not_to allow_value(0) } + it { is_expected.not_to allow_value('23,20') } + it { is_expected.not_to allow_value('13/*') } + it { is_expected.not_to allow_value('2/5') } + it { is_expected.not_to allow_value('13-/15') } + end + context 'with silly things' do + it { is_expected.not_to allow_value([]) } + it { is_expected.not_to allow_value('.') } + it { is_expected.not_to allow_value('') } + it { is_expected.not_to allow_value('1 ') } + it { is_expected.not_to allow_value('5 1') } + it { is_expected.not_to allow_value(:undef) } + end + end end end diff --git a/spec/type_aliases/cron/monthday_spec.rb b/spec/type_aliases/cron/monthday_spec.rb index 2346827a..3e9c1f29 100644 --- a/spec/type_aliases/cron/monthday_spec.rb +++ b/spec/type_aliases/cron/monthday_spec.rb @@ -1,20 +1,26 @@ require 'spec_helper' describe 'Simplib::Cron::MonthDay' do - context 'with valid parameters' do - it { is_expected.to allow_value([22]) } - it { is_expected.to allow_value(['22']) } - it { is_expected.to allow_value(['20-23', '10-14/2', 3, 5, '19']) } - it { is_expected.to allow_value(22) } - it { is_expected.to allow_value('22') } - it { is_expected.to allow_value('20-23') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('1-23/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value(['20-23', '10-14/2', 3, 33, 5, '19']) } - it { is_expected.not_to allow_value(['0,1,12-19,5']) } - it { is_expected.not_to allow_value(["'0','1','12-19','5'"]) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value([22]) } + it { is_expected.to allow_value(['22']) } + it { is_expected.to allow_value(['20-23', '10-14/2', 3, 5, '19']) } + it { is_expected.to allow_value(22) } + it { is_expected.to allow_value('22') } + it { is_expected.to allow_value('20-23') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('1-23/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value(['20-23', '10-14/2', 3, 33, 5, '19']) } + it { is_expected.not_to allow_value(['0,1,12-19,5']) } + it { is_expected.not_to allow_value(["'0','1','12-19','5'"]) } + end + end end end diff --git a/spec/type_aliases/cron/weekday_entry_spec.rb b/spec/type_aliases/cron/weekday_entry_spec.rb index b8b776d6..4726f271 100644 --- a/spec/type_aliases/cron/weekday_entry_spec.rb +++ b/spec/type_aliases/cron/weekday_entry_spec.rb @@ -1,41 +1,47 @@ require 'spec_helper' describe 'Simplib::Cron::WeekDay_entry' do - context 'with valid parameters' do - it { is_expected.to allow_value(0) } - it { is_expected.to allow_value('0') } - it { is_expected.to allow_value(2) } - it { is_expected.to allow_value('2') } - it { is_expected.to allow_value('7') } # Sunday can be 0 or 7 - it { is_expected.to allow_value(7) } # Sunday can be 0 or 7 - it { is_expected.to allow_value('SUN') } - it { is_expected.to allow_value('sun') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('0-4') } - it { is_expected.to allow_value('0-6/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value('SUN,MON,WED,TUE') } - it { is_expected.not_to allow_value('SUNDAY') } - it { is_expected.not_to allow_value('1,4-5') } - it { is_expected.not_to allow_value('1,MON,3,5') } - it { is_expected.not_to allow_value('TUE-FRI') } - it { is_expected.not_to allow_value('TUE-5') } - it { is_expected.not_to allow_value('TUE/3') } - it { is_expected.not_to allow_value('/3') } - it { is_expected.not_to allow_value('-2') } - it { is_expected.not_to allow_value('9') } - it { is_expected.not_to allow_value('3/*') } - it { is_expected.not_to allow_value('3/5') } - it { is_expected.not_to allow_value('3-/5') } - end - context 'with silly things' do - it { is_expected.not_to allow_value([]) } - it { is_expected.not_to allow_value('.') } - it { is_expected.not_to allow_value('') } - it { is_expected.not_to allow_value('1 ') } - it { is_expected.not_to allow_value('5 1') } - it { is_expected.not_to allow_value(:undef) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value(0) } + it { is_expected.to allow_value('0') } + it { is_expected.to allow_value(2) } + it { is_expected.to allow_value('2') } + it { is_expected.to allow_value('7') } # Sunday can be 0 or 7 + it { is_expected.to allow_value(7) } # Sunday can be 0 or 7 + it { is_expected.to allow_value('SUN') } + it { is_expected.to allow_value('sun') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('0-4') } + it { is_expected.to allow_value('0-6/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value('SUN,MON,WED,TUE') } + it { is_expected.not_to allow_value('SUNDAY') } + it { is_expected.not_to allow_value('1,4-5') } + it { is_expected.not_to allow_value('1,MON,3,5') } + it { is_expected.not_to allow_value('TUE-FRI') } + it { is_expected.not_to allow_value('TUE-5') } + it { is_expected.not_to allow_value('TUE/3') } + it { is_expected.not_to allow_value('/3') } + it { is_expected.not_to allow_value('-2') } + it { is_expected.not_to allow_value('9') } + it { is_expected.not_to allow_value('3/*') } + it { is_expected.not_to allow_value('3/5') } + it { is_expected.not_to allow_value('3-/5') } + end + context 'with silly things' do + it { is_expected.not_to allow_value([]) } + it { is_expected.not_to allow_value('.') } + it { is_expected.not_to allow_value('') } + it { is_expected.not_to allow_value('1 ') } + it { is_expected.not_to allow_value('5 1') } + it { is_expected.not_to allow_value(:undef) } + end + end end end diff --git a/spec/type_aliases/cron/weekday_spec.rb b/spec/type_aliases/cron/weekday_spec.rb index 99e59c62..7bdf9bb0 100644 --- a/spec/type_aliases/cron/weekday_spec.rb +++ b/spec/type_aliases/cron/weekday_spec.rb @@ -1,22 +1,28 @@ require 'spec_helper' describe 'Simplib::Cron::WeekDay' do - context 'with valid parameters' do - it { is_expected.to allow_value([2]) } - it { is_expected.to allow_value(['2']) } - it { is_expected.to allow_value(['MON']) } - it { is_expected.to allow_value(['mon']) } - it { is_expected.to allow_value(['5-6', '1-2/2', '*/3', 'THU']) } - it { is_expected.to allow_value(2) } - it { is_expected.to allow_value('2') } - it { is_expected.to allow_value('2-3') } - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('*/5') } - it { is_expected.to allow_value('0-6/2') } - end - context 'with invalid parameters' do - it { is_expected.not_to allow_value(['5-6', '1-2/2', '*/8']) } - it { is_expected.not_to allow_value(['0,1,2-3,5']) } - it { is_expected.not_to allow_value(["'0','1','2-3','5'"]) } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid parameters' do + it { is_expected.to allow_value([2]) } + it { is_expected.to allow_value(['2']) } + it { is_expected.to allow_value(['MON']) } + it { is_expected.to allow_value(['mon']) } + it { is_expected.to allow_value(['5-6', '1-2/2', '*/3', 'THU']) } + it { is_expected.to allow_value(2) } + it { is_expected.to allow_value('2') } + it { is_expected.to allow_value('2-3') } + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('*/5') } + it { is_expected.to allow_value('0-6/2') } + end + context 'with invalid parameters' do + it { is_expected.not_to allow_value(['5-6', '1-2/2', '*/8']) } + it { is_expected.not_to allow_value(['0,1,2-3,5']) } + it { is_expected.not_to allow_value(["'0','1','2-3','5'"]) } + end + end end end diff --git a/spec/type_aliases/domain_spec.rb b/spec/type_aliases/domain_spec.rb index 98803bb7..187f694d 100644 --- a/spec/type_aliases/domain_spec.rb +++ b/spec/type_aliases/domain_spec.rb @@ -4,54 +4,60 @@ # Tests cover RFC 3696, Section 2 # RegEx + test cases developed at http://rubular.com/r/4yZ7R8v42f - context 'with valid DNS domain names' do - context 'Only ASCII alpha + numbers + hyphens are allowed' do - it { is_expected.to allow_value('test.com') } - it { is_expected.to allow_value('test') } - it { is_expected.to allow_value('t') } - it { is_expected.to allow_value('0.t-t.0.t') } - it { is_expected.to allow_value('0-0') } - it { is_expected.to allow_value('0-0.0-0.0-0') } - it { is_expected.to allow_value('0f') } - it { is_expected.to allow_value('f0') } - it { is_expected.to allow_value('test.00f') } - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } - context 'TLDs may end with a trailing period' do - it { is_expected.to allow_value('t.') } - it { is_expected.to allow_value('test.com.') } - end - end + context 'with valid DNS domain names' do + context 'Only ASCII alpha + numbers + hyphens are allowed' do + it { is_expected.to allow_value('test.com') } + it { is_expected.to allow_value('test') } + it { is_expected.to allow_value('t') } + it { is_expected.to allow_value('0.t-t.0.t') } + it { is_expected.to allow_value('0-0') } + it { is_expected.to allow_value('0-0.0-0.0-0') } + it { is_expected.to allow_value('0f') } + it { is_expected.to allow_value('f0') } + it { is_expected.to allow_value('test.00f') } + end - context 'with invalid DNS domain names' do - context "labels can't begin or end with hyphens" do - it { is_expected.not_to allow_value('-test') } - it { is_expected.not_to allow_value('test-') } - it { is_expected.not_to allow_value('test-.test') } - it { is_expected.not_to allow_value('test.-test') } - end + context 'TLDs may end with a trailing period' do + it { is_expected.to allow_value('t.') } + it { is_expected.to allow_value('test.com.') } + end + end - context 'TLDs cannot be all-numeric' do - it { is_expected.not_to allow_value('0') } - it { is_expected.not_to allow_value('0212') } - it { is_expected.not_to allow_value('test.0') } - it { is_expected.not_to allow_value('t.t.t.t.0') } - end + context 'with invalid DNS domain names' do + context "labels can't begin or end with hyphens" do + it { is_expected.not_to allow_value('-test') } + it { is_expected.not_to allow_value('test-') } + it { is_expected.not_to allow_value('test-.test') } + it { is_expected.not_to allow_value('test.-test') } + end - context 'A DNS label may be no more than 63 octets long' do - it { is_expected.not_to allow_value('an-extremely-long-dns-label-that-is-just-over-63-characters-long.test') } - it { is_expected.not_to allow_value('test.an-extremely-long-dns-label-that-is-just-over-63-characters-long') } - it { is_expected.not_to allow_value('test.an-extremely-long-dns-label-that-is-just-over-63-characters-long.test') } - it { is_expected.not_to allow_value('an-extremely-long-dns-label-that-is-just-over-63-characters-long.') } - end - end + context 'TLDs cannot be all-numeric' do + it { is_expected.not_to allow_value('0') } + it { is_expected.not_to allow_value('0212') } + it { is_expected.not_to allow_value('test.0') } + it { is_expected.not_to allow_value('t.t.t.t.0') } + end - context 'with silly things' do - it { is_expected.not_to allow_value([]) } - it { is_expected.not_to allow_value('.') } - it { is_expected.not_to allow_value('') } - it { is_expected.not_to allow_value('test.c m') } - it { is_expected.not_to allow_value("test.com\n") } - it { is_expected.not_to allow_value(:undef) } + context 'A DNS label may be no more than 63 octets long' do + it { is_expected.not_to allow_value('an-extremely-long-dns-label-that-is-just-over-63-characters-long.test') } + it { is_expected.not_to allow_value('test.an-extremely-long-dns-label-that-is-just-over-63-characters-long') } + it { is_expected.not_to allow_value('test.an-extremely-long-dns-label-that-is-just-over-63-characters-long.test') } + it { is_expected.not_to allow_value('an-extremely-long-dns-label-that-is-just-over-63-characters-long.') } + end + end + + context 'with silly things' do + it { is_expected.not_to allow_value([]) } + it { is_expected.not_to allow_value('.') } + it { is_expected.not_to allow_value('') } + it { is_expected.not_to allow_value('test.c m') } + it { is_expected.not_to allow_value("test.com\n") } + it { is_expected.not_to allow_value(:undef) } + end + end end end diff --git a/spec/type_aliases/domainlist_spec.rb b/spec/type_aliases/domainlist_spec.rb index bfca6329..9ffa9b2e 100644 --- a/spec/type_aliases/domainlist_spec.rb +++ b/spec/type_aliases/domainlist_spec.rb @@ -1,14 +1,20 @@ require 'spec_helper' describe 'Simplib::Domainlist' do - context 'with valid DNS domain names' do - it { is_expected.to allow_value(['test.com', 'test', 't.', '0.t-t.0.t', '0-0.0-0']) } - it { is_expected.to allow_value(['0-0']) } - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid DNS domain names' do + it { is_expected.to allow_value(['test.com', 'test', 't.', '0.t-t.0.t', '0-0.0-0']) } + it { is_expected.to allow_value(['0-0']) } + end - context 'with invalid DNS domain names' do - it { is_expected.not_to allow_value(['test.com', 'test', 't', 'test-.com']) } - it { is_expected.not_to allow_value(['-test']) } - it { is_expected.not_to allow_value(['t.t.t.t.0', 'test.com']) } + context 'with invalid DNS domain names' do + it { is_expected.not_to allow_value(['test.com', 'test', 't', 'test-.com']) } + it { is_expected.not_to allow_value(['-test']) } + it { is_expected.not_to allow_value(['t.t.t.t.0', 'test.com']) } + end + end end end diff --git a/spec/type_aliases/shadowpass_spec.rb b/spec/type_aliases/shadowpass_spec.rb index 2e0e12d2..913d185c 100644 --- a/spec/type_aliases/shadowpass_spec.rb +++ b/spec/type_aliases/shadowpass_spec.rb @@ -1,22 +1,28 @@ require 'spec_helper' describe 'Simplib::ShadowPass' do - context 'with valid entries' do - it { is_expected.to allow_value('*') } - it { is_expected.to allow_value('!') } - it { is_expected.to allow_value('!!') } - it { is_expected.to allow_value('!!i$6$h6k81gwg$J5QJ3DWz9G2CeIHMEXRfhd7Ocem.NNfQimxw/OUa2m/PD3Mx6q67ntjELlVgye4kHxG5ZfMAXLjioGWISJYFE1') } - it { is_expected.to allow_value('$6$h6k81gwg$J5QJ3DWz9G2CeIHMEXRfhd7Ocem.NNfQimxw/OUa2m/PD3Mx6q67ntjELlVgye4kHxG5ZfMAXLjioGWISJYFE1') } - it { is_expected.to allow_value('$5$4E8kXNLiykgBk$NviJTE3NgOvqoF0hXlhFbbYknIpTZqqVqihav8ZM2h9') } - it { is_expected.to allow_value('$3$$0480cf9c8755c691c629f6595c2e7238') } - it { is_expected.to allow_value('$2a$07$ybS56Js6xCcu5SxFwa2NsODRF109WEitIY52THiZh.eFdfQg8ovNe') } - it { is_expected.to allow_value('$2y$10$RT.Z68QWbhbg5.TOba4gGOBEvj6anWfvPBaU3F1HMHTSz5g75Vrme') } - it { is_expected.to allow_value('$1$0nIBDEfm$QNNyqbDS5ZkwScfmvI37z.') } - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid entries' do + it { is_expected.to allow_value('*') } + it { is_expected.to allow_value('!') } + it { is_expected.to allow_value('!!') } + it { is_expected.to allow_value('!!i$6$h6k81gwg$J5QJ3DWz9G2CeIHMEXRfhd7Ocem.NNfQimxw/OUa2m/PD3Mx6q67ntjELlVgye4kHxG5ZfMAXLjioGWISJYFE1') } + it { is_expected.to allow_value('$6$h6k81gwg$J5QJ3DWz9G2CeIHMEXRfhd7Ocem.NNfQimxw/OUa2m/PD3Mx6q67ntjELlVgye4kHxG5ZfMAXLjioGWISJYFE1') } + it { is_expected.to allow_value('$5$4E8kXNLiykgBk$NviJTE3NgOvqoF0hXlhFbbYknIpTZqqVqihav8ZM2h9') } + it { is_expected.to allow_value('$3$$0480cf9c8755c691c629f6595c2e7238') } + it { is_expected.to allow_value('$2a$07$ybS56Js6xCcu5SxFwa2NsODRF109WEitIY52THiZh.eFdfQg8ovNe') } + it { is_expected.to allow_value('$2y$10$RT.Z68QWbhbg5.TOba4gGOBEvj6anWfvPBaU3F1HMHTSz5g75Vrme') } + it { is_expected.to allow_value('$1$0nIBDEfm$QNNyqbDS5ZkwScfmvI37z.') } + end - context 'with invalid entries' do - it { is_expected.not_to allow_value('*$6$h6k81gwg$J5QJ3DWz9G2CeIHMEXRfhd7Ocem.NNfQimxw/OUa2m/PD3Mx6q67ntjELlVgye4kHxG5ZfMAXLjioGWISJYFE1') } - it { is_expected.not_to allow_value('$6$') } - it { is_expected.not_to allow_value('mycleartextpassword') } + context 'with invalid entries' do + it { is_expected.not_to allow_value('*$6$h6k81gwg$J5QJ3DWz9G2CeIHMEXRfhd7Ocem.NNfQimxw/OUa2m/PD3Mx6q67ntjELlVgye4kHxG5ZfMAXLjioGWISJYFE1') } + it { is_expected.not_to allow_value('$6$') } + it { is_expected.not_to allow_value('mycleartextpassword') } + end + end end end diff --git a/spec/type_aliases/simplib_macaddress_spec.rb b/spec/type_aliases/simplib_macaddress_spec.rb index 82762328..d33665a7 100644 --- a/spec/type_aliases/simplib_macaddress_spec.rb +++ b/spec/type_aliases/simplib_macaddress_spec.rb @@ -1,18 +1,24 @@ require 'spec_helper' describe 'Simplib::Macaddress' do - context 'with valid MAC addresses' do - it { is_expected.to allow_value('CA:FE:BE:EF:00:11') } - it { is_expected.to allow_value('ca:fe:be:ef:00:11') } - it { is_expected.to allow_value('12:34:56:78:90:11') } - it { is_expected.to allow_value('Ca:fE:0e:F1:00:11') } - it { is_expected.to allow_value('0:1:2:3:4:5') } - it { is_expected.to allow_value('A0:B:2C:D:E4:F') } - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + context 'with valid MAC addresses' do + it { is_expected.to allow_value('CA:FE:BE:EF:00:11') } + it { is_expected.to allow_value('ca:fe:be:ef:00:11') } + it { is_expected.to allow_value('12:34:56:78:90:11') } + it { is_expected.to allow_value('Ca:fE:0e:F1:00:11') } + it { is_expected.to allow_value('0:1:2:3:4:5') } + it { is_expected.to allow_value('A0:B:2C:D:E4:F') } + end - context 'with invalid MAC addresses' do - it { is_expected.not_to allow_value('CA:FE:BE:EF:00:') } - it { is_expected.not_to allow_value('CA:FE:BE:EF::11') } - it { is_expected.not_to allow_value('OO:PS:NO:TH:EX:11') } + context 'with invalid MAC addresses' do + it { is_expected.not_to allow_value('CA:FE:BE:EF:00:') } + it { is_expected.not_to allow_value('CA:FE:BE:EF::11') } + it { is_expected.not_to allow_value('OO:PS:NO:TH:EX:11') } + end + end end end diff --git a/spec/unit/data_types/emailaddress_spec.rb b/spec/unit/data_types/emailaddress_spec.rb index 017253ba..e4956977 100644 --- a/spec/unit/data_types/emailaddress_spec.rb +++ b/spec/unit/data_types/emailaddress_spec.rb @@ -2,41 +2,46 @@ describe 'Simplib::EmailAddress', type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - Simplib::EmailAddress $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + Simplib::EmailAddress $param, + ) { } - class { '#{class_name}': - param => '#{param}', - } - END - end + class { '#{class_name}': + param => '#{param}', + } + END + end - context 'with valid addresses' do - [ - 'foo@bar.baz', - 'foo@bar', - 'foo@bar-baz.com', - 'foobar@bar-baz.com', - 'foo+bar@bar-baz.com', - 'foo.bar@bar-baz.com', - ].each do |param| - let(:param) { param } + context 'with valid addresses' do + [ + 'foo@bar.baz', + 'foo@bar', + 'foo@bar-baz.com', + 'foobar@bar-baz.com', + 'foo+bar@bar-baz.com', + 'foo.bar@bar-baz.com', + ].each do |param| + let(:param) { param } - it "accepts #{param}" do - is_expected.to compile + it "accepts #{param}" do + is_expected.to compile + end + end end - end - end - context 'with invalid addresses' do - [ 'foo' ].each do |param| - let(:param) { param } + context 'with invalid addresses' do + [ 'foo' ].each do |param| + let(:param) { param } - it "accepts #{param}" do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it "accepts #{param}" do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/host/port_spec.rb b/spec/unit/data_types/host/port_spec.rb index c8719eef..fd3fc566 100644 --- a/spec/unit/data_types/host/port_spec.rb +++ b/spec/unit/data_types/host/port_spec.rb @@ -22,39 +22,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/host_spec.rb b/spec/unit/data_types/host_spec.rb index 405f927c..cede9853 100644 --- a/spec/unit/data_types/host_spec.rb +++ b/spec/unit/data_types/host_spec.rb @@ -28,39 +28,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/hostname/port_spec.rb b/spec/unit/data_types/hostname/port_spec.rb index b4739027..130e1313 100644 --- a/spec/unit/data_types/hostname/port_spec.rb +++ b/spec/unit/data_types/hostname/port_spec.rb @@ -28,39 +28,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/hostname_spec.rb b/spec/unit/data_types/hostname_spec.rb index d1e9199d..c27d5ce4 100644 --- a/spec/unit/data_types/hostname_spec.rb +++ b/spec/unit/data_types/hostname_spec.rb @@ -30,39 +30,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/ip/v4/cidr_spec.rb b/spec/unit/data_types/ip/v4/cidr_spec.rb index 3e246e69..b4f5eeec 100644 --- a/spec/unit/data_types/ip/v4/cidr_spec.rb +++ b/spec/unit/data_types/ip/v4/cidr_spec.rb @@ -29,39 +29,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip/v4/ddq_spec.rb b/spec/unit/data_types/ip/v4/ddq_spec.rb index 0e168b96..49029801 100644 --- a/spec/unit/data_types/ip/v4/ddq_spec.rb +++ b/spec/unit/data_types/ip/v4/ddq_spec.rb @@ -30,39 +30,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip/v4/port_spec.rb b/spec/unit/data_types/ip/v4/port_spec.rb index 8bba2219..1874e682 100644 --- a/spec/unit/data_types/ip/v4/port_spec.rb +++ b/spec/unit/data_types/ip/v4/port_spec.rb @@ -30,39 +30,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip/v4_spec.rb b/spec/unit/data_types/ip/v4_spec.rb index 3fcea717..1fc5fb62 100644 --- a/spec/unit/data_types/ip/v4_spec.rb +++ b/spec/unit/data_types/ip/v4_spec.rb @@ -24,39 +24,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip/v6/base_spec.rb b/spec/unit/data_types/ip/v6/base_spec.rb index 4011fb83..b8d029e3 100644 --- a/spec/unit/data_types/ip/v6/base_spec.rb +++ b/spec/unit/data_types/ip/v6/base_spec.rb @@ -26,39 +26,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip/v6/bracketed_spec.rb b/spec/unit/data_types/ip/v6/bracketed_spec.rb index f1754174..23bf5057 100644 --- a/spec/unit/data_types/ip/v6/bracketed_spec.rb +++ b/spec/unit/data_types/ip/v6/bracketed_spec.rb @@ -26,39 +26,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip/v6/cidr_spec.rb b/spec/unit/data_types/ip/v6/cidr_spec.rb index 751282ad..f3104203 100644 --- a/spec/unit/data_types/ip/v6/cidr_spec.rb +++ b/spec/unit/data_types/ip/v6/cidr_spec.rb @@ -27,39 +27,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip/v6/port_spec.rb b/spec/unit/data_types/ip/v6/port_spec.rb index 4a650298..f2d285b2 100644 --- a/spec/unit/data_types/ip/v6/port_spec.rb +++ b/spec/unit/data_types/ip/v6/port_spec.rb @@ -28,39 +28,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip/v6_spec.rb b/spec/unit/data_types/ip/v6_spec.rb index 1dd59030..ead522a3 100644 --- a/spec/unit/data_types/ip/v6_spec.rb +++ b/spec/unit/data_types/ip/v6_spec.rb @@ -27,39 +27,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/ip_spec.rb b/spec/unit/data_types/ip_spec.rb index d7175391..e03068f6 100644 --- a/spec/unit/data_types/ip_spec.rb +++ b/spec/unit/data_types/ip_spec.rb @@ -26,39 +26,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/netlist/host_spec.rb b/spec/unit/data_types/netlist/host_spec.rb index 4916b7ad..08c93467 100644 --- a/spec/unit/data_types/netlist/host_spec.rb +++ b/spec/unit/data_types/netlist/host_spec.rb @@ -33,39 +33,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/netlist/ip/v4_spec.rb b/spec/unit/data_types/netlist/ip/v4_spec.rb index ccd948a6..834489fb 100644 --- a/spec/unit/data_types/netlist/ip/v4_spec.rb +++ b/spec/unit/data_types/netlist/ip/v4_spec.rb @@ -28,39 +28,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/netlist/ip/v6_spec.rb b/spec/unit/data_types/netlist/ip/v6_spec.rb index ec04556c..3c5af15e 100644 --- a/spec/unit/data_types/netlist/ip/v6_spec.rb +++ b/spec/unit/data_types/netlist/ip/v6_spec.rb @@ -33,39 +33,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/netlist/ip_spec.rb b/spec/unit/data_types/netlist/ip_spec.rb index b0e72b1c..9781536c 100644 --- a/spec/unit/data_types/netlist/ip_spec.rb +++ b/spec/unit/data_types/netlist/ip_spec.rb @@ -28,39 +28,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/netlist/port_spec.rb b/spec/unit/data_types/netlist/port_spec.rb index db267c71..0916c517 100644 --- a/spec/unit/data_types/netlist/port_spec.rb +++ b/spec/unit/data_types/netlist/port_spec.rb @@ -33,39 +33,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/netlist_spec.rb b/spec/unit/data_types/netlist_spec.rb index 1de75f54..ee10151d 100644 --- a/spec/unit/data_types/netlist_spec.rb +++ b/spec/unit/data_types/netlist_spec.rb @@ -32,39 +32,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/port/dynamic_spec.rb b/spec/unit/data_types/port/dynamic_spec.rb index 7d8fd31f..2e7d7ada 100644 --- a/spec/unit/data_types/port/dynamic_spec.rb +++ b/spec/unit/data_types/port/dynamic_spec.rb @@ -4,34 +4,39 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context 'with valid ports' do - [49_152, 56_789, 65_535].each do |param| - let(:param) { param } + context 'with valid ports' do + [49_152, 56_789, 65_535].each do |param| + let(:param) { param } - it "works with port #{param}" do - is_expected.to compile + it "works with port #{param}" do + is_expected.to compile + end + end end - end - end - context 'with invalid ports' do - [0, 49_151, 65_536, '22', true].each do |param| - let(:param) { param } + context 'with invalid ports' do + [0, 49_151, 65_536, '22', true].each do |param| + let(:param) { param } - it "fails on port #{param}" do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it "fails on port #{param}" do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/port/random_spec.rb b/spec/unit/data_types/port/random_spec.rb index 98aa3317..6e66eaf6 100644 --- a/spec/unit/data_types/port/random_spec.rb +++ b/spec/unit/data_types/port/random_spec.rb @@ -4,34 +4,39 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context 'with valid ports' do - [0].each do |param| - let(:param) { param } + context 'with valid ports' do + [0].each do |param| + let(:param) { param } - it "works with port #{param}" do - is_expected.to compile + it "works with port #{param}" do + is_expected.to compile + end + end end - end - end - context 'with invalid ports' do - [1, 1025, '22', true].each do |param| - let(:param) { param } + context 'with invalid ports' do + [1, 1025, '22', true].each do |param| + let(:param) { param } - it "fails on port #{param}" do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it "fails on port #{param}" do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/port/system_spec.rb b/spec/unit/data_types/port/system_spec.rb index 432505c6..dfd8fa4b 100644 --- a/spec/unit/data_types/port/system_spec.rb +++ b/spec/unit/data_types/port/system_spec.rb @@ -4,34 +4,39 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context 'with valid ports' do - [1, 80, 1024].each do |param| - let(:param) { param } + context 'with valid ports' do + [1, 80, 1024].each do |param| + let(:param) { param } - it "works with port #{param}" do - is_expected.to compile + it "works with port #{param}" do + is_expected.to compile + end + end end - end - end - context 'with invalid ports' do - [0, 1025, '22', true].each do |param| - let(:param) { param } + context 'with invalid ports' do + [0, 1025, '22', true].each do |param| + let(:param) { param } - it "fails on port #{param}" do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it "fails on port #{param}" do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/port/user_spec.rb b/spec/unit/data_types/port/user_spec.rb index fb56ec74..cadbdb76 100644 --- a/spec/unit/data_types/port/user_spec.rb +++ b/spec/unit/data_types/port/user_spec.rb @@ -4,34 +4,39 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context 'with valid ports' do - [1025, 2345, 49_151].each do |param| - let(:param) { param } + context 'with valid ports' do + [1025, 2345, 49_151].each do |param| + let(:param) { param } - it "works with port #{param}" do - is_expected.to compile + it "works with port #{param}" do + is_expected.to compile + end + end end - end - end - context 'with invalid ports' do - [0, 1024, '22', 49_152, 65_535, true].each do |param| - let(:param) { param } + context 'with invalid ports' do + [0, 1024, '22', 49_152, 65_535, true].each do |param| + let(:param) { param } - it "fails on port #{param}" do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it "fails on port #{param}" do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/port_spec.rb b/spec/unit/data_types/port_spec.rb index e133d8b2..351fc43e 100644 --- a/spec/unit/data_types/port_spec.rb +++ b/spec/unit/data_types/port_spec.rb @@ -2,34 +2,39 @@ describe 'Simplib::Port', type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - Simplib::Port $port, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + Simplib::Port $port, + ) { } - class { '#{class_name}': - port => #{port}, - } - END - end + class { '#{class_name}': + port => #{port}, + } + END + end - context 'with valid ports' do - [0, 80, 1024, 65_535].each do |port| - let(:port) { port } + context 'with valid ports' do + [0, 80, 1024, 65_535].each do |port| + let(:port) { port } - it "works with port #{port}" do - is_expected.to compile + it "works with port #{port}" do + is_expected.to compile + end + end end - end - end - context 'with invalid ports' do - [-1, 65_536, 12_345_678_910, '22', true].each do |port| - let(:port) { port } + context 'with invalid ports' do + [-1, 65_536, 12_345_678_910, '22', true].each do |port| + let(:port) { port } - it "fails on port #{port}" do - is_expected.to compile.and_raise_error(%r{parameter 'port' expects}) + it "fails on port #{port}" do + is_expected.to compile.and_raise_error(%r{parameter 'port' expects}) + end + end end end end diff --git a/spec/unit/data_types/shadowpass_spec.rb b/spec/unit/data_types/shadowpass_spec.rb index 2fc04084..8e87684b 100644 --- a/spec/unit/data_types/shadowpass_spec.rb +++ b/spec/unit/data_types/shadowpass_spec.rb @@ -2,18 +2,23 @@ describe 'Simplib::ShadowPass', type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - Simplib::ShadowPass $foo = '$6$fdkjfdk$yj8HAo/RyW/WhYkXvTp7nQbjIZz4TMRuj/0W1bJGuQjGxea36JhUkB36BMyf8O/g0/rpRB1lPC/6KuAmgqnIn0', - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + Simplib::ShadowPass $foo = '$6$fdkjfdk$yj8HAo/RyW/WhYkXvTp7nQbjIZz4TMRuj/0W1bJGuQjGxea36JhUkB36BMyf8O/g0/rpRB1lPC/6KuAmgqnIn0', + ) { } - include #{class_name} - END - end + include #{class_name} + END + end - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end end diff --git a/spec/unit/data_types/syslog/cfacility_spec.rb b/spec/unit/data_types/syslog/cfacility_spec.rb index 9bc592cc..8425714d 100644 --- a/spec/unit/data_types/syslog/cfacility_spec.rb +++ b/spec/unit/data_types/syslog/cfacility_spec.rb @@ -17,39 +17,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end + + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/cpriority_spec.rb b/spec/unit/data_types/syslog/cpriority_spec.rb index b8784956..b6f7657e 100644 --- a/spec/unit/data_types/syslog/cpriority_spec.rb +++ b/spec/unit/data_types/syslog/cpriority_spec.rb @@ -17,39 +17,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end + + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/cseverity_spec.rb b/spec/unit/data_types/syslog/cseverity_spec.rb index 7acd67c4..e6bdd530 100644 --- a/spec/unit/data_types/syslog/cseverity_spec.rb +++ b/spec/unit/data_types/syslog/cseverity_spec.rb @@ -17,39 +17,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end + + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/facility_spec.rb b/spec/unit/data_types/syslog/facility_spec.rb index 6595f156..8ec58c69 100644 --- a/spec/unit/data_types/syslog/facility_spec.rb +++ b/spec/unit/data_types/syslog/facility_spec.rb @@ -21,39 +21,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/lowerfacility_spec.rb b/spec/unit/data_types/syslog/lowerfacility_spec.rb index cdab34dd..d9b3914a 100644 --- a/spec/unit/data_types/syslog/lowerfacility_spec.rb +++ b/spec/unit/data_types/syslog/lowerfacility_spec.rb @@ -18,39 +18,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/lowerpriority_spec.rb b/spec/unit/data_types/syslog/lowerpriority_spec.rb index eeeb93ef..aebe397f 100644 --- a/spec/unit/data_types/syslog/lowerpriority_spec.rb +++ b/spec/unit/data_types/syslog/lowerpriority_spec.rb @@ -17,39 +17,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end + + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/lowerseverity_spec.rb b/spec/unit/data_types/syslog/lowerseverity_spec.rb index e4df7df4..efca8790 100644 --- a/spec/unit/data_types/syslog/lowerseverity_spec.rb +++ b/spec/unit/data_types/syslog/lowerseverity_spec.rb @@ -19,39 +19,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/priority_spec.rb b/spec/unit/data_types/syslog/priority_spec.rb index 7dabe558..c87ed5a3 100644 --- a/spec/unit/data_types/syslog/priority_spec.rb +++ b/spec/unit/data_types/syslog/priority_spec.rb @@ -19,39 +19,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/severity_spec.rb b/spec/unit/data_types/syslog/severity_spec.rb index 9b25cdf3..bd5fbde8 100644 --- a/spec/unit/data_types/syslog/severity_spec.rb +++ b/spec/unit/data_types/syslog/severity_spec.rb @@ -21,39 +21,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/upperfacility_spec.rb b/spec/unit/data_types/syslog/upperfacility_spec.rb index d33827ba..c5f90fcc 100644 --- a/spec/unit/data_types/syslog/upperfacility_spec.rb +++ b/spec/unit/data_types/syslog/upperfacility_spec.rb @@ -18,39 +18,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/upperpriority_spec.rb b/spec/unit/data_types/syslog/upperpriority_spec.rb index db31b139..95a148ef 100644 --- a/spec/unit/data_types/syslog/upperpriority_spec.rb +++ b/spec/unit/data_types/syslog/upperpriority_spec.rb @@ -19,39 +19,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/syslog/upperseverity_spec.rb b/spec/unit/data_types/syslog/upperseverity_spec.rb index 83a1e157..38033379 100644 --- a/spec/unit/data_types/syslog/upperseverity_spec.rb +++ b/spec/unit/data_types/syslog/upperseverity_spec.rb @@ -19,39 +19,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } - - class { '#{class_name}': - param => #{param}, - } - END - end + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } + + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/systemd/servicename_spec.rb b/spec/unit/data_types/systemd/servicename_spec.rb index 41ed3753..f0b5f92a 100644 --- a/spec/unit/data_types/systemd/servicename_spec.rb +++ b/spec/unit/data_types/systemd/servicename_spec.rb @@ -25,39 +25,44 @@ describe test_data_type, type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - #{test_data_type} $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + #{test_data_type} $param, + ) { } - class { '#{class_name}': - param => #{param}, - } - END - end + class { '#{class_name}': + param => #{param}, + } + END + end - context "with valid #{plural_item}" do - valid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) { data.is_a?(String) ? "'#{data}'" : data } + context "with valid #{plural_item}" do + valid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) { data.is_a?(String) ? "'#{data}'" : data } - it 'compiles' do - is_expected.to compile + it 'compiles' do + is_expected.to compile + end + end end end - end - end - context "with invalid #{plural_item}" do - invalid_data.each do |data| - context "with #{singular_item} #{data}" do - let(:param) do - data.is_a?(String) ? "'#{data}'" : data - end + context "with invalid #{plural_item}" do + invalid_data.each do |data| + context "with #{singular_item} #{data}" do + let(:param) do + data.is_a?(String) ? "'#{data}'" : data + end - it 'fails to compile' do - is_expected.to compile.and_raise_error(%r{parameter 'param'}) + it 'fails to compile' do + is_expected.to compile.and_raise_error(%r{parameter 'param'}) + end + end end end end diff --git a/spec/unit/data_types/umask_spec.rb b/spec/unit/data_types/umask_spec.rb index 3130e534..bbcc4f03 100644 --- a/spec/unit/data_types/umask_spec.rb +++ b/spec/unit/data_types/umask_spec.rb @@ -2,41 +2,46 @@ describe 'Simplib::Umask', type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - Simplib::Umask $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + Simplib::Umask $param, + ) { } - class { '#{class_name}': - param => '#{param}', - } - END - end + class { '#{class_name}': + param => '#{param}', + } + END + end - context 'with valid umask' do - [ - '0000', - '0240', - '1111', - ].each do |param| - let(:param) { param } + context 'with valid umask' do + [ + '0000', + '0240', + '1111', + ].each do |param| + let(:param) { param } - it "accepts #{param}" do - is_expected.to compile + it "accepts #{param}" do + is_expected.to compile + end + end end - end - end - context 'with invalid umask' do - [ - '12345', - 'bob', - ].each do |param| - let(:param) { param } + context 'with invalid umask' do + [ + '12345', + 'bob', + ].each do |param| + let(:param) { param } - it "rejects #{param}" do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it "rejects #{param}" do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end diff --git a/spec/unit/data_types/uri_spec.rb b/spec/unit/data_types/uri_spec.rb index dd8d0137..f375ecf5 100644 --- a/spec/unit/data_types/uri_spec.rb +++ b/spec/unit/data_types/uri_spec.rb @@ -2,43 +2,48 @@ describe 'Simplib::URI', type: :class do describe 'valid handling' do - let(:pre_condition) do - <<~END - class #{class_name} ( - Simplib::URI $param, - ) { } + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + let(:pre_condition) do + <<~END + class #{class_name} ( + Simplib::URI $param, + ) { } - class { '#{class_name}': - param => '#{param}', - } - END - end + class { '#{class_name}': + param => '#{param}', + } + END + end - context 'with valid URI' do - [ - 'foo://bar', - 'f00://bar', - 'foo+bar://baz', - 'foo.bar-baz+aaa://bbb', - ].each do |param| - let(:param) { param } + context 'with valid URI' do + [ + 'foo://bar', + 'f00://bar', + 'foo+bar://baz', + 'foo.bar-baz+aaa://bbb', + ].each do |param| + let(:param) { param } - it "accepts #{param}" do - is_expected.to compile + it "accepts #{param}" do + is_expected.to compile + end + end end - end - end - context 'with invalid URI' do - [ - 'foo', - 'foo@bar://baz', - '1foo://bar', - ].each do |param| - let(:param) { param } + context 'with invalid URI' do + [ + 'foo', + 'foo@bar://baz', + '1foo://bar', + ].each do |param| + let(:param) { param } - it "rejects #{param}" do - is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + it "rejects #{param}" do + is_expected.to compile.and_raise_error(%r{parameter 'param' expects}) + end + end end end end