Sha256: bd9d81eca5a0d9f1cf6fc1ba4680cd7598ecf486c32b30e81881d21775da13de

Contents?: true

Size: 1.24 KB

Versions: 34

Compression:

Stored size: 1.24 KB

Contents

require_relative "../base"

require Vagrant.source_root.join("plugins/providers/virtualbox/cap/public_address")

describe VagrantPlugins::ProviderVirtualBox::Cap::PublicAddress do
  include_context "unit"

  let(:iso_env) do
    # We have to create a Vagrantfile so there is a root path
    env = isolated_environment
    env.vagrantfile("")
    env.create_vagrant_env
  end

  let(:machine) do
    iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m|
      allow(m).to receive(:state).and_return(state)
    end
  end

  let(:state) do
    double(:state)
  end

  describe "#public_address" do
    it "returns nil when the machine is not running" do
      allow(state).to receive(:id).and_return(:not_created)
      expect(described_class.public_address(machine)).to be(nil)
    end

    it "returns nil when there is no ssh info" do
      allow(state).to receive(:id).and_return(:not_created)
      allow(machine).to receive(:ssh_info).and_return(nil)
      expect(described_class.public_address(machine)).to be(nil)
    end

    it "returns the host" do
      allow(state).to receive(:id).and_return(:running)
      allow(machine).to receive(:ssh_info).and_return(host: "test")
      expect(described_class.public_address(machine)).to eq("test")
    end
  end
end

Version data entries

34 entries across 30 versions & 6 rubygems

Version Path
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-unbundled-2.0.2.0 test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-unbundled-2.0.1.0 test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-unbundled-2.0.0.1 test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-unbundled-1.9.8.1 test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-unbundled-1.9.7.1 test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/providers/virtualbox/cap/public_address_test.rb