spec/facts_spec.rb in facterdb-1.24.0 vs spec/facts_spec.rb in facterdb-2.1.0

- old
+ new

@@ -78,13 +78,22 @@ facter_dir_path = File.basename(File.dirname(filepath)) expect(content['facterversion']).to have_facter_version(facter_dir_path, filepath) end + # when facts are generated with distro facter or rubygems facter the augeas bindings might be missing + # we need to ensure they exist + it 'contains the augeas.version fact' do + if content['kernel'] == 'Linux' + expect(content['augeas']['version']).to not_be_nil.and not_be_empty + end + end + it 'contains newer networking facts hash' do if Gem::Version.new(content['facterversion']) >= Gem::Version.new('3.0.0') expect(content['networking']['ip']).to not_be_nil.and not_be_empty + expect(content['networking']['ip6']).to not_be_nil.and not_be_empty expect(content['networking']['hostname']).to eq('foo') expect(content['networking']['domain']).to eq('example.com') expect(content['networking']['fqdn']).to eq('foo.example.com') end end @@ -107,28 +116,15 @@ expect(content['systemd']).to be_nil expect(content['systemd_version']).to be_nil expect(content['systemd_internal_services']).to be_nil end - it 'contains a legacy hostname, domain and fqdn fact' do - expect(content['hostname']).to eq('foo') - expect(content['fqdn']).to eq('foo.example.com') - expect(content['domain']).to eq('example.com') - end - - it 'contains the legacy osfamily fact' do - expect(content['osfamily']).not_to be_nil - end - - it 'contains the legacy operatingsystem fact' do - expect(content['operatingsystem']).not_to be_nil - end - - # the fact got introduced in 1.5.5 and is confined to kernel=linux - # https://github.com/puppetlabs/facter/blob/1.6.0/lib/facter/selinux.rb - # f94abfccfd6687a88f62703e4005c28ec04467a1 from facter - it 'contains the legacy selinux fact' do - expect(content['selinux']).not_to be_nil if content['kernel'] == 'Linux' + # those are used in newer rspec-puppet-facts versions + # by ensuring those facts exists, we can drop a huge amount of logic in rspec-puppet-facts + it 'contains the mandatory OS facts' do + expect(content['os']['release']['major']).to not_be_nil.and not_be_empty + expect(content['os']['name']).to not_be_nil.and not_be_empty + expect(content['os']['hardware']).to not_be_nil.and not_be_empty end end end end