Sha256: f23978c13a0d9474266e3bdbc8d95fc22b8eccfa6d9c3de3f716228d9609ee0e

Contents?: true

Size: 1.12 KB

Versions: 17

Compression:

Stored size: 1.12 KB

Contents

require_relative "base"

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

describe VagrantPlugins::ProviderVirtualBox::Cap 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|
      m.provider.stub(driver: driver)
      m.stub(state: state)
    end
  end

  let(:driver) { double("driver") }
  let(:state)  { double("state", id: :running) }

  describe "#forwarded_ports" do
    it "returns all the forwarded ports" do
      allow(driver).to receive(:read_forwarded_ports).and_return([
        [nil, nil, 123, 456],
        [nil, nil, 245, 245],
      ])

      expect(described_class.forwarded_ports(machine)).to eq({
        123 => 456,
        245 => 245,
      })
    end

    it "returns nil when the machine is not running" do
      allow(machine).to receive(:state).and_return(double(:state, id: :stopped))
      expect(described_class.forwarded_ports(machine)).to be(nil)
    end
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
vagrant-unbundled-1.9.7.1 test/unit/plugins/providers/virtualbox/cap_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_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_test.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-unbundled-1.9.5.1 test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-unbundled-1.9.1.1 test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-unbundled-1.8.5.2 test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-unbundled-1.8.5.1 test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-unbundled-1.8.4.2 test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-unbundled-1.8.4.1 test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-unbundled-1.8.1.2 test/unit/plugins/providers/virtualbox/cap_test.rb
vagrant-unbundled-1.8.1.1 test/unit/plugins/providers/virtualbox/cap_test.rb