Sha256: f5641a32c2417f68e8d899fe3a4236f811360251e216fbd555910f04981c4b6f

Contents?: true

Size: 1.62 KB

Versions: 5

Compression:

Stored size: 1.62 KB

Contents

require 'vagrant-conoha/spec_helper'

describe VagrantPlugins::ConoHa::Command::NetworkList do
  describe 'cmd' do
    let(:neutron) do
      double('neutron').tap do |neutron|
        neutron.stub(:get_private_networks) do
          [
            Item.new('net-01', 'internal'),
            Item.new('net-02', 'external')
          ]
        end
        neutron.stub(:get_all_networks) do
          [
            Item.new('pub-01', 'public'),
            Item.new('net-01', 'internal'),
            Item.new('net-02', 'external')
          ]
        end
      end
    end

    let(:env) do
      {}.tap do |env|
        env[:ui] = double('ui')
        env[:ui].stub(:info).with(anything)
        env[:openstack_client] = double
        env[:openstack_client].stub(:neutron) { neutron }
      end
    end

    before :each do
      @network_list_cmd = VagrantPlugins::ConoHa::Command::NetworkList.new(nil, env)
    end

    it 'prints network list from server' do
      neutron.should_receive(:get_private_networks).with(env)

      expect(env[:ui]).to receive(:info).with('
+--------+----------+
| ID     | Name     |
+--------+----------+
| net-01 | internal |
| net-02 | external |
+--------+----------+')

      @network_list_cmd.cmd('network-list', [], env)
    end

    it 'prints all networks list from server' do
      neutron.should_receive(:get_all_networks).with(env)

      expect(env[:ui]).to receive(:info).with('
+--------+----------+
| ID     | Name     |
+--------+----------+
| pub-01 | public   |
| net-01 | internal |
| net-02 | external |
+--------+----------+')

      @network_list_cmd.cmd('network-list', ['all'], env)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-conoha-0.1.10 spec/vagrant-conoha/command/network_list_spec.rb
vagrant-conoha-0.1.9 spec/vagrant-conoha/command/network_list_spec.rb
vagrant-conoha-0.1.8 spec/vagrant-conoha/command/network_list_spec.rb
vagrant-conoha-0.1.7 spec/vagrant-conoha/command/network_list_spec.rb
vagrant-conoha-0.1.6 spec/vagrant-conoha/command/network_list_spec.rb