spec/platform_spec.rb in phantomjs-1.6.0.0 vs spec/platform_spec.rb in phantomjs-1.8.1.0

- old
+ new

@@ -1,23 +1,57 @@ require 'spec_helper' describe Phantomjs::Platform do before(:each) { Phantomjs.reset! } + describe "with a system install present" do + describe "#system_phantomjs_installed?" do + it "is true when the system version matches Phantomjs.version" do + Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return(Phantomjs.version) + expect(Phantomjs::Platform.system_phantomjs_installed?).to be_true + end + + it "is false when the system version does not match Phantomjs.version" do + Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return('1.2.3') + expect(Phantomjs::Platform.system_phantomjs_installed?).to be_false + end + + it "is false when there's no system version" do + Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return(nil) + expect(Phantomjs::Platform.system_phantomjs_installed?).to be_false + end + end + end + describe "on a 64 bit linux" do before do Phantomjs::Platform.stub(:host_os).and_return('linux-gnu') Phantomjs::Platform.stub(:architecture).and_return('x86_64') end it "reports the Linux64 Platform as useable" do Phantomjs::Platform::Linux64.should be_useable end - it "returns the correct phantom js executable path for the platform" do - Phantomjs.path.should =~ /x86_64-linux\/bin\/phantomjs$/ + describe "without system install" do + before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) } + + it "returns the correct phantom js executable path for the platform" do + Phantomjs.path.should =~ /x86_64-linux\/bin\/phantomjs$/ + end end + describe "with system install" do + before(:each) do + Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version) + Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path') + end + + it "returns the correct phantom js executable path for the platform" do + expect(Phantomjs.path).to be == '/tmp/path' + end + end + it "reports the Linux32 platform as unuseable" do Phantomjs::Platform::Linux32.should_not be_useable end it "reports the Darwin platform as unuseable" do @@ -39,14 +73,29 @@ Phantomjs::Platform.stub(:host_os).and_return('linux-gnu') Phantomjs::Platform.stub(:architecture).and_return('i686') Phantomjs::Platform::Linux32.should be_useable end - it "returns the correct phantom js executable path for the platform" do - Phantomjs.path.should =~ /x86_32-linux\/bin\/phantomjs$/ + describe "without system install" do + before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) } + + it "returns the correct phantom js executable path for the platform" do + Phantomjs.path.should =~ /x86_32-linux\/bin\/phantomjs$/ + end end + describe "with system install" do + before(:each) do + Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version) + Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path') + end + + it "returns the correct phantom js executable path for the platform" do + expect(Phantomjs.path).to be == '/tmp/path' + end + end + it "reports the Linux64 platform as unuseable" do Phantomjs::Platform::Linux64.should_not be_useable end it "reports the Darwin platform as unuseable" do @@ -62,11 +111,26 @@ it "reports the Darwin platform as useable" do Phantomjs::Platform::OsX.should be_useable end - it "returns the correct phantom js executable path for the platform" do - Phantomjs.path.should =~ /darwin\/bin\/phantomjs$/ + describe "without system install" do + before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) } + + it "returns the correct phantom js executable path for the platform" do + Phantomjs.path.should =~ /darwin\/bin\/phantomjs$/ + end + end + + describe "with system install" do + before(:each) do + Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version) + Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path') + end + + it "returns the correct phantom js executable path for the platform" do + expect(Phantomjs.path).to be == '/tmp/path' + end end it "reports the Linux32 Platform as unuseable" do Phantomjs::Platform::Linux32.should_not be_useable end