Skip to content

Commit 9a92e9d

Browse files
authored
Merge pull request #98 from sambrightman/partial-uninstall
Fix uninstall
2 parents f389724 + 035f56a commit 9a92e9d

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

lib/evm/package.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def uninstall!
7171
end
7272

7373
if current?
74-
FileUtils.rm(Evm::EVM_EMACS_PATH)
74+
disuse!
7575
end
7676
end
7777

spec/evm/package_spec.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,28 @@
200200
@foo.uninstall!
201201
end
202202

203-
it 'should remove binary symlink if current' do
204-
expect(FileUtils).to receive(:rm).with(Evm::EVM_EMACS_PATH)
205-
203+
it 'should remove shims and unset current if current' do
206204
allow(@foo).to receive(:current?).and_return(true)
205+
allow(config).to receive(:[]).with(:path).and_return(@foo.path)
206+
allow(Evm).to receive(:config).and_return(config)
207+
208+
expect(file_class).to receive(:exists?).with(Evm::EMACS_PATH).and_return(true)
209+
expect(file_class).to receive(:exists?).with(Evm::EVM_EMACS_PATH).and_return(true)
210+
expect(file_class).to receive(:delete).with(Evm::EVM_EMACS_PATH)
211+
expect(file_class).to receive(:delete).with(Evm::EMACS_PATH)
212+
expect(config).to receive(:[]=).with(:current, nil)
207213

208214
@foo.uninstall!
209215
end
210216

211-
it 'should not remove binary symlink file if not current' do
212-
expect(FileUtils).not_to receive(:rm).with(Evm::EVM_EMACS_PATH)
213-
217+
it 'should not remove shims or unset current if not current' do
214218
allow(@foo).to receive(:current?).and_return(false)
219+
allow(config).to receive(:[]).with(:path).and_return(@foo.path)
220+
allow(Evm).to receive(:config).and_return(config)
221+
222+
expect(file_class).not_to receive(:delete).with(Evm::EVM_EMACS_PATH)
223+
expect(file_class).not_to receive(:delete).with(Evm::EMACS_PATH)
224+
expect(config).not_to receive(:[]=)
215225

216226
@foo.uninstall!
217227
end

0 commit comments

Comments
 (0)