# frozen_string_literal: true

describe Facts::Solaris::Networking::Dhcp do
  describe '#call_the_resolver' do
    subject(:fact) { Facts::Solaris::Networking::Dhcp.new }

    let(:value) { '10.16.122.163' }

    before do
      allow(Facter::Resolvers::Solaris::Networking).to receive(:resolve).with(:dhcp).and_return(value)
    end

    it 'returns dhcp fact' do
      expect(fact.call_the_resolver)
        .to be_an_instance_of(Facter::ResolvedFact)
        .and have_attributes(name: 'networking.dhcp', value: value)
    end

    context 'when dhcp can not be retrieved' do
      let(:value) { nil }

      it 'returns nil' do
        expect(fact.call_the_resolver)
          .to be_an_instance_of(Facter::ResolvedFact).and have_attributes(name: 'networking.dhcp', value: value)
      end
    end
  end
end
