File: remove_libvirt_image_spec.rb

package info (click to toggle)
vagrant-libvirt 0.12.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,756 kB
  • sloc: ruby: 12,865; xml: 2,465; sh: 373; javascript: 235; makefile: 13
file content (42 lines) | stat: -rw-r--r-- 1,129 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

require_relative '../../spec_helper'

require 'vagrant-libvirt/action/remove_libvirt_image'

describe VagrantPlugins::ProviderLibvirt::Action::RemoveLibvirtImage do
  subject { described_class.new(app, env) }

  include_context 'unit'

  let(:box) { instance_double(::Vagrant::Box) }

  describe '#call' do
    before do
      env[:box_removed] = box
      allow(ui).to receive(:info)
    end

    context 'when called with libvirt box removed' do
      before do
        expect(box).to receive(:provider).and_return(:libvirt)
      end

      it 'should notify the user about limited removal' do
        expect(ui).to receive(:info).with(/Vagrant-libvirt plugin removed box/)
        expect(subject.call(env)).to be_nil
      end
    end

    context 'when called with any other provider box' do
      before do
        expect(box).to receive(:provider).and_return(:virtualbox)
      end

      it 'call the next middle ware immediately' do
        expect(ui).to_not receive(:info).with(/Vagrant-libvirt plugin removed box/)
        expect(subject.call(env)).to be_nil
      end
    end
  end
end