Sha256: 7fb65e29ef3c41585458f1688ea37ceab939a4b9e402b69750628917534a32f2

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

require 'vagrant-conoha/spec_helper'

describe VagrantPlugins::ConoHa::Command::SubnetList do
  describe 'cmd' do
    let(:neutron) do
      double('neutron').tap do |neutron|
        neutron.stub(:get_subnets) do
          [
            Subnet.new('subnet-01', 'Subnet 1', '192.168.1.0/24', true, 'net-01'),
            Subnet.new('subnet-02', 'Subnet 2', '192.168.2.0/24', false, 'net-01'),
            Subnet.new('subnet-03', 'Subnet 3', '192.168.100.0/24', true, 'net-02')
          ]
        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
      @subnet_list_cmd = VagrantPlugins::ConoHa::Command::SubnetList.new(nil, env)
    end

    it 'prints subnet list from server' do
      neutron.should_receive(:get_subnets).with(env)

      expect(env[:ui]).to receive(:info).with('
+-----------+----------+------------------+-------+------------+
| ID        | Name     | CIDR             | DHCP  | Network ID |
+-----------+----------+------------------+-------+------------+
| subnet-01 | Subnet 1 | 192.168.1.0/24   | true  | net-01     |
| subnet-02 | Subnet 2 | 192.168.2.0/24   | false | net-01     |
| subnet-03 | Subnet 3 | 192.168.100.0/24 | true  | net-02     |
+-----------+----------+------------------+-------+------------+')

      @subnet_list_cmd.cmd('subnet-list', [], 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/subnet_list_spec.rb
vagrant-conoha-0.1.9 spec/vagrant-conoha/command/subnet_list_spec.rb
vagrant-conoha-0.1.8 spec/vagrant-conoha/command/subnet_list_spec.rb
vagrant-conoha-0.1.7 spec/vagrant-conoha/command/subnet_list_spec.rb
vagrant-conoha-0.1.6 spec/vagrant-conoha/command/subnet_list_spec.rb