Sha256: 8ffb4ec15656d639a032450f04acdb87a55c9854b1fac0f7b60b9d2d94f0a818

Contents?: true

Size: 931 Bytes

Versions: 3

Compression:

Stored size: 931 Bytes

Contents

require File.expand_path('../../spec_helper.rb', __FILE__)

RSpec.describe Xhyve::DHCP do
  let(:leases) do
    {
      '9a:65:1b:12:cf:0f' => '192.168.64.35',
      '9a:65:1b:12:cf:32' => '192.168.64.34',
      'a6:84:b2:34:cf:32' => '192.168.64.5',
      'ea:28:a:33:cf:32' => '192.168.64.4',
      'e2:ff:e:70:cf:32' => '192.168.64.3',
      '5a:90:52:13:cf:32' => '192.168.64.2'
    }
  end

  before :all do
    ENV['LEASES_FILE'] = File.join(FIXTURE_PATH, 'dhcpd_leases.txt')
    ENV['MAX_IP_WAIT'] = '1'
  end

  after :all do
    ENV.delete('LEASES_FILE')
    ENV.delete('MAX_IP_WAIT')
  end

  it 'parses the leases file to get an IP from a MAC' do
    leases.each do |mac, ip|
      expect(Xhyve::DHCP.get_ip_for_mac(mac)).to_not be_nil
      expect(Xhyve::DHCP.get_ip_for_mac(mac)).to eq(ip)
    end
  end

  it 'returns nil if no lease is found' do
    expect(Xhyve::DHCP.get_ip_for_mac('fakemac')).to be_nil
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
vagrant-hyperkit-0.4.3 vendor/xhyve-ruby/spec/lib/dhcp_spec.rb
vagrant-xhyve-0.4.1 vendor/xhyve-ruby/spec/lib/dhcp_spec.rb
vagrant-xhyve-0.4.0 vendor/xhyve-ruby/spec/lib/dhcp_spec.rb