Sha256: a8df7348122d5c4e997dd5d635b5bfd59fcb00ef36d4416558f8209d7a8272eb

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

require_relative "../../../../base"

describe "VagrantPlugins::GuestRedHat::Cap::ConfigureNetworks" do
  let(:caps) do
    VagrantPlugins::GuestRedHat::Plugin
      .components
      .guest_capabilities[:redhat]
  end

  let(:guest) { double("guest") }
  let(:machine) { double("machine", guest: guest) }
  let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }

  before do
    allow(machine).to receive(:communicate).and_return(comm)
  end

  after do
    comm.verify_expectations!
  end

  describe ".configure_networks" do
    let(:cap) { caps.get(:configure_networks) }

    before do
      allow(guest).to receive(:capability)
        .with(:network_scripts_dir)
        .and_return("/scripts")

      allow(guest).to receive(:capability)
        .with(:network_interfaces)
        .and_return(["eth1", "eth2"])
    end

    let(:network_1) do
      {
        interface: 0,
        type: "dhcp",
      }
    end

    let(:network_2) do
      {
        interface: 1,
        type: "static",
        ip: "33.33.33.10",
        netmask: "255.255.0.0",
        gateway: "33.33.0.1",
      }
    end

    it "creates and starts the networks" do
      allow(guest).to receive(:capability)
        .with(:flavor)
        .and_return(:rhel)

      cap.configure_networks(machine, [network_1, network_2])
      expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth1'/)
      expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth1'/)
      expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth2'/)
      expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth2'/)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-unbundled-1.8.5.2 test/unit/plugins/guests/redhat/cap/configure_networks_test.rb
vagrant-unbundled-1.8.5.1 test/unit/plugins/guests/redhat/cap/configure_networks_test.rb