spec/facter_db_spec.rb in facterdb-2.1.0 vs spec/facter_db_spec.rb in facterdb-3.0.0

- old
+ new

@@ -195,95 +195,10 @@ expect(json_database).to all(include('_facterdb_path' => anything)) end end end - describe '.get_os_facts' do - subject(:result) { FacterDB.get_os_facts(facter_version, filter) } - - before do - object = defined?(Warning) ? Warning : Kernel - allow(object).to receive(:warn).and_call_original - allow(object).to receive(:warn).with(a_string_matching(/`get_os_facts` is deprecated/)) - end - - context 'without parameters' do - subject(:result) { FacterDB.get_os_facts } - - include_examples 'returns a result' - end - - context 'when matching all Facter versions' do - let(:facter_version) { '*' } - - context 'with an Array filter' do - let(:filter) { [{ osfamily: 'Debian' }] } - - include_examples 'returns a result' - end - - context 'with a Hash filter' do - let(:filter) { { osfamily: 'Debian' } } - - include_examples 'returns a result' - end - - context 'with a String filter' do - let(:filter) { 'osfamily=Debian' } - - include_examples 'returns a result' - end - - context 'with a filter of an unsupported type' do - let(:filter) { true } - - it 'raises an error' do - expect { result }.to raise_error(/filter must be either/) - end - end - end - - context 'when matching a specific facter version' do - let(:facter_version) { '4.0.52' } - - shared_examples 'returns only the specified version' do - it 'only includes fact sets for the specified version' do - expect(result).to all(include(facterversion: match(/^4\.0/))) - end - end - - context 'with an Array filter' do - let(:filter) { [{ osfamily: 'Debian' }] } - - include_examples 'returns a result' - include_examples 'returns only the specified version' - end - - context 'with a Hash filter' do - let(:filter) { { osfamily: 'Debian' } } - - include_examples 'returns a result' - include_examples 'returns only the specified version' - end - - context 'with a String filter' do - let(:filter) { 'osfamily=Debian' } - - include_examples 'returns a result' - include_examples 'returns only the specified version' - end - - context 'with a filter of an unsupported type' do - let(:filter) { true } - - it 'raises an error' do - expect { result }.to raise_error(/filter must be either/) - end - end - end - end - describe '.valid_filters?' do it 'invalid and false' do expect(FacterDB.valid_filters?('and')).to be_falsey end @@ -300,15 +215,15 @@ it 'with string' do expect(FacterDB.generate_filter_str('foo')).to eq('foo') end it 'with hash' do - expect(FacterDB.generate_filter_str({ osfamily: 'Debian' })).to eq('osfamily=Debian') + expect(FacterDB.generate_filter_str({ kernel: 'Linux' })).to eq('kernel=Linux') end it 'with Array' do - expect(FacterDB.generate_filter_str([osfamily: 'Debian'])).to eq('(osfamily=Debian)') + expect(FacterDB.generate_filter_str([kernel: 'Linux'])).to eq('(kernel=Linux)') end it 'empty' do expect(FacterDB.generate_filter_str('')).to eq('') end @@ -347,22 +262,22 @@ end end end context 'with an Array filter' do - let(:filter) { [osfamily: 'Debian'] } + let(:filter) { [kernel: 'Linux'] } include_examples 'returns a result' end context 'with a Hash filter' do - let(:filter) { { osfamily: 'Debian' } } + let(:filter) { { kernel: 'Linux' } } include_examples 'returns a result' end context 'with a String filter' do - let(:filter) { 'osfamily=Debian' } + let(:filter) { 'kernel=Linux' } include_examples 'returns a result' end context 'with a filter of an unsupported type' do