Sha256: dcd45572cd62a2e261f3893731439c3a71a3f361bcbd585fe12e40f078d9101d

Contents?: true

Size: 1.2 KB

Versions: 11

Compression:

Stored size: 1.2 KB

Contents

require 'vagrant-conoha/spec_helper'

describe VagrantPlugins::ConoHa::Action::Suspend do
  let(:nova) do
    double('nova').tap do |nova|
      nova.stub(:suspend_server)
    end
  end

  let(:env) do
    {}.tap do |env|
      env[:ui] = double('ui').tap do |ui|
        ui.stub(:info).with(anything)
        ui.stub(:error).with(anything)
      end
      env[:openstack_client] = double('openstack_client').tap do |os|
        os.stub(:nova) { nova }
      end
      env[:machine] = OpenStruct.new
    end
  end

  let(:app) do
    double('app').tap do |app|
      app.stub(:call).with(anything)
    end
  end

  describe 'call' do
    context 'when server id is present' do
      it 'starts the server' do
        env[:machine].id = 'server_id'
        expect(nova).to receive(:suspend_server).with(env, 'server_id')
        expect(app).to receive(:call)
        @action = Suspend.new(app, nil)
        @action.call(env)
      end
    end
    context 'when server id is not present' do
      it 'does nothing' do
        env[:machine].id = nil
        expect(nova).to_not receive(:suspend_server)
        expect(app).to receive(:call)
        @action = Suspend.new(app, nil)
        @action.call(env)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vagrant-conoha-0.1.10 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.9 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.8 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.7 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.6 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.5 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.4 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.3 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.2 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.1 spec/vagrant-conoha/action/suspend_server_spec.rb
vagrant-conoha-0.1.0 spec/vagrant-conoha/action/suspend_server_spec.rb