From 8baf7ced38b9cedc99bbd595f98cedc036baad7f Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 17 Jul 2018 15:16:38 -0700 Subject: [PATCH] Use path of state file, not state file itself --- .../commands/plugin/action/expunge_plugins.rb | 4 ++-- .../plugin/action/expunge_plugins_test.rb | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/commands/plugin/action/expunge_plugins.rb b/plugins/commands/plugin/action/expunge_plugins.rb index 97d5e907c..3327d57df 100644 --- a/plugins/commands/plugin/action/expunge_plugins.rb +++ b/plugins/commands/plugin/action/expunge_plugins.rb @@ -47,13 +47,13 @@ module VagrantPlugins # Do not include global paths if local only if !env[:env_local] - files << Vagrant::Plugin::Manager.instance.user_file + files << Vagrant::Plugin::Manager.instance.user_file.path dirs << Vagrant::Bundler.instance.plugin_gem_path end # Add local paths if they exist if Vagrant::Plugin::Manager.instance.local_file - files << Vagrant::Plugin::Manager.instance.local_file + files << Vagrant::Plugin::Manager.instance.local_file.path dirs << Vagrant::Bundler.instance.env_plugin_gem_path end diff --git a/test/unit/plugins/commands/plugin/action/expunge_plugins_test.rb b/test/unit/plugins/commands/plugin/action/expunge_plugins_test.rb index a758afbc0..4b1d50257 100644 --- a/test/unit/plugins/commands/plugin/action/expunge_plugins_test.rb +++ b/test/unit/plugins/commands/plugin/action/expunge_plugins_test.rb @@ -14,7 +14,8 @@ describe VagrantPlugins::CommandPlugin::Action::ExpungePlugins do env_local: env_local }} - let(:user_file) { double("user_file", exist?: true, delete: true) } + let(:user_file) { double("user_file", path: user_file_pathname) } + let(:user_file_pathname) { double("user_file_pathname", exist?: true, delete: true) } let(:local_file) { nil } let(:bundler) { double("bundler", plugin_gem_path: plugin_gem_path, env_plugin_gem_path: env_plugin_gem_path) } @@ -44,7 +45,7 @@ describe VagrantPlugins::CommandPlugin::Action::ExpungePlugins do end it "should delete all plugins" do - expect(user_file).to receive(:delete) + expect(user_file_pathname).to receive(:delete) expect(plugin_gem_path).to receive(:rmtree) subject.call(env) end @@ -75,19 +76,20 @@ describe VagrantPlugins::CommandPlugin::Action::ExpungePlugins do let(:env_local) { true } it "should not delete plugins" do - expect(user_file).not_to receive(:delete) + expect(user_file_pathname).not_to receive(:delete) expect(plugin_gem_path).not_to receive(:rmtree) subject.call(env) end end context "when local plugins exist" do - let(:local_file) { double("local_file", exist?: true, delete: true) } + let(:local_file) { double("local_file", path: local_file_pathname) } + let(:local_file_pathname) { double("local_file_pathname", exist?: true, delete: true) } let(:env_plugin_gem_path) { double("env_plugin_gem_path", exist?: true, rmtree: true) } it "should delete user and local plugins" do - expect(user_file).to receive(:delete) - expect(local_file).to receive(:delete) + expect(user_file_pathname).to receive(:delete) + expect(local_file_pathname).to receive(:delete) expect(plugin_gem_path).to receive(:rmtree) expect(env_plugin_gem_path).to receive(:rmtree) subject.call(env) @@ -97,13 +99,13 @@ describe VagrantPlugins::CommandPlugin::Action::ExpungePlugins do let(:env_local) { true } it "should delete local plugins" do - expect(local_file).to receive(:delete) + expect(local_file_pathname).to receive(:delete) expect(env_plugin_gem_path).to receive(:rmtree) subject.call(env) end it "should not delete user plugins" do - expect(user_file).not_to receive(:delete) + expect(user_file_pathname).not_to receive(:delete) expect(plugin_gem_path).not_to receive(:rmtree) subject.call(env) end