Sha256: 361f251fc7847da1dcf10ce1a5e2599731bf2f2914218dcd778249213ccdc3f0

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

require 'vagrant-openstack-provider/spec_helper'

describe VagrantPlugins::Openstack::Action::Resume do
  let(:nova) do
    double('nova').tap do |nova|
      nova.stub(:resume_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(:resume_server).with(env, 'server_id')
        expect(app).to receive(:call)
        @action = Resume.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(:resume_server)
        expect(app).to receive(:call)
        @action = Resume.new(app, nil)
        @action.call(env)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
vagrant-openstack-provider-0.13.0 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-0.12.0 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-illuin-0.11.1 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-0.11.0 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-0.10.0 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-0.9.0 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-0.8.0 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-0.7.2 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-0.7.1 spec/vagrant-openstack-provider/action/resume_server_spec.rb
vagrant-openstack-provider-0.7.0 spec/vagrant-openstack-provider/action/resume_server_spec.rb