summaryrefslogtreecommitdiff
path: root/spec/bundler/plugins/uninstall_spec.rb
blob: 555c6a7002325e6c6327cc70b6eae3768705eead (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# frozen_string_literal: true

RSpec.describe "bundler plugin uninstall" do
  before do
    build_repo2 do
      build_plugin "foo"
      build_plugin "kung-foo"
    end
  end

  it "shows proper error message when plugins are not specified" do
    bundle "plugin uninstall"
    expect(err).to include("No plugins to uninstall")
  end

  it "uninstalls specified plugins" do
    bundle "plugin install foo kung-foo --source #{file_uri_for(gem_repo2)}"
    plugin_should_be_installed("foo")
    plugin_should_be_installed("kung-foo")

    bundle "plugin uninstall foo"
    expect(out).to include("Uninstalled plugin foo")
    plugin_should_not_be_installed("foo")
    plugin_should_be_installed("kung-foo")
  end

  it "shows proper message when plugin is not installed" do
    bundle "plugin uninstall foo"
    expect(err).to include("Plugin foo is not installed")
    plugin_should_not_be_installed("foo")
  end

  it "doesn't wipe out path plugins" do
    build_lib "path_plugin" do |s|
      s.write "plugins.rb"
    end
    path = lib_path("path_plugin-1.0")
    expect(path).to be_a_directory

    allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)

    install_gemfile <<-G
      source '#{file_uri_for(gem_repo2)}'
      plugin 'path_plugin', :path => "#{path}"
      gem 'rack', '1.0.0'
    G

    plugin_should_be_installed("path_plugin")
    expect(Bundler::Plugin.index.plugin_path("path_plugin")).to eq path

    bundle "plugin uninstall path_plugin"
    expect(out).to include("Uninstalled plugin path_plugin")
    plugin_should_not_be_installed("path_plugin")
    # the actual gem still exists though
    expect(path).to be_a_directory
  end

  describe "with --all" do
    it "uninstalls all installed plugins" do
      bundle "plugin install foo kung-foo --source #{file_uri_for(gem_repo2)}"
      plugin_should_be_installed("foo")
      plugin_should_be_installed("kung-foo")

      bundle "plugin uninstall --all"
      plugin_should_not_be_installed("foo")
      plugin_should_not_be_installed("kung-foo")
    end

    it "shows proper no plugins installed message when no plugins installed" do
      bundle "plugin uninstall --all"
      expect(out).to include("No plugins installed")
    end
  end
end