Sha256: 39af4ae3fa451dcce0304515fd859c5b7a2b10ab4a381ab82a9e131a06b5088d

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

require 'vagrant-openstack-provider/spec_helper'

describe VagrantPlugins::Openstack::Action::Suspend do

  let(:nova) do
    double('nova').tap do |nova|
      nova.stub(:suspend_server)
    end
  end

  let(:env) do
    Hash.new.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

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.6.1 spec/vagrant-openstack-provider/action/suspend_server_spec.rb
vagrant-openstack-provider-0.6.0 spec/vagrant-openstack-provider/action/suspend_server_spec.rb
vagrant-openstack-provider-0.5.2 spec/vagrant-openstack-provider/action/suspend_server_spec.rb
vagrant-openstack-provider-0.5.1 spec/vagrant-openstack-provider/action/suspend_server_spec.rb
vagrant-openstack-provider-0.5.0 spec/vagrant-openstack-provider/action/suspend_server_spec.rb