File: update_gems_test.rb

package info (click to toggle)
vagrant 2.3.7%2Bgit20230731.5fc64cde%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 17,616 kB
  • sloc: ruby: 111,820; sh: 462; makefile: 123; ansic: 34; lisp: 1
file content (35 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download | duplicates (5)
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
require File.expand_path("../../../../../base", __FILE__)

describe VagrantPlugins::CommandPlugin::Action::UpdateGems do
  let(:app) { lambda { |env| } }
  let(:env) {{
    ui: Vagrant::UI::Silent.new
  }}

  let(:manager) { double("manager") }

  subject { described_class.new(app, env) }

  before do
    allow(Vagrant::Plugin::Manager).to receive(:instance).and_return(manager)
    allow(manager).to receive(:installed_specs).and_return([])
  end

  describe "#call" do
    it "should update all plugins if none are specified" do
      expect(manager).to receive(:update_plugins).with([]).once.and_return([])
      expect(manager).to receive(:installed_plugins).twice.and_return({})
      expect(app).to receive(:call).with(env).once
      subject.call(env)
    end

    it "should update specified plugins" do
      expect(manager).to receive(:update_plugins).with(["foo"]).once.and_return([])
      expect(manager).to receive(:installed_plugins).twice.and_return({})
      expect(app).to receive(:call).with(env).once

      env[:plugin_name] = ["foo"]
      subject.call(env)
    end
  end
end