Sha256: 1673daa02ef34df0bd7e9766c210e485ac8be651757576fd4ef967067c3189e9

Contents?: true

Size: 1.33 KB

Versions: 15

Compression:

Stored size: 1.33 KB

Contents

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

describe "VagrantPlugins::GuestFreeBSD::Cap::ConfigureNetworks" do
  let(:described_class) do
    VagrantPlugins::GuestFreeBSD::Plugin
      .components
      .guest_capabilities[:freebsd]
      .get(:configure_networks)
  end

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

  before do
    allow(machine).to receive(:communicate).and_return(comm)
    comm.stub_command("ifconfig -a | grep -o ^[0-9a-z]* | grep -v '^lo'",
      stdout: "em1\nem2")
  end

  after do
    comm.verify_expectations!
  end

  describe ".configure_networks" do
    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
      described_class.configure_networks(machine, [network_1, network_2])
      expect(comm.received_commands[1]).to match(/dhclient 'em1'/)
      expect(comm.received_commands[1]).to match(/\/etc\/rc.d\/netif restart 'em1'/)

      expect(comm.received_commands[1]).to_not match(/dhclient 'em2'/)
      expect(comm.received_commands[1]).to match(/\/etc\/rc.d\/netif restart 'em2'/)
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
vagrant-unbundled-1.9.7.1 test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-unbundled-1.9.5.1 test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-unbundled-1.9.1.1 test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-unbundled-1.8.5.2 test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-unbundled-1.8.5.1 test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-unbundled-1.8.4.2 test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb
vagrant-unbundled-1.8.4.1 test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb