From 4761ac4ca588e9f5e2c94aee524f39ae6448cefa Mon Sep 17 00:00:00 2001 From: Ruslan Ledesma Garza Date: Sat, 23 Jul 2016 22:55:43 -0500 Subject: [PATCH] Implode Phantomjs when installed in custom base dir. --- lib/phantomjs.rb | 2 +- spec/phantomjs_spec.rb | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/phantomjs.rb b/lib/phantomjs.rb index 54c9adb..6435b8e 100644 --- a/lib/phantomjs.rb +++ b/lib/phantomjs.rb @@ -36,7 +36,7 @@ def platform # Removes the local phantomjs copy def implode! - FileUtils.rm_rf File.join(File.expand_path('~'), '.phantomjs') + FileUtils.rm_rf base_dir end # Clears cached state. Primarily useful for testing. diff --git a/spec/phantomjs_spec.rb b/spec/phantomjs_spec.rb index 87ce51f..1acea86 100644 --- a/spec/phantomjs_spec.rb +++ b/spec/phantomjs_spec.rb @@ -47,4 +47,13 @@ lines.should eq(["bar foo1\n", "bar foo2\n"]) end end -end \ No newline at end of file + + describe ".implode!" do + it "removes the local phantomjs copy from custom base_dir" do + Phantomjs.base_dir = '/tmp/base_dir' + Phantomjs.path.platform.installed?.should be_true + Phantomjs.implode! + Dir.exist?('/tmp/base_dir').should be_false + end + end +end