Ver Fonte

Begin renaming binary_path to binary

This is half of a commit that will be combining binary_name and
binary_path.
Daniel Gempesaw há 10 anos atrás
pai
commit
5083039f9e

+ 3 - 8
lib/Selenium/CanStartBinary.pm

@@ -1,6 +1,7 @@
 package Selenium::CanStartBinary;
 
 # ABSTRACT: Teach a WebDriver how to start its own binary aka no JRE!
+use Cwd qw/abs_path/;
 use File::Which qw/which/;
 use IO::Socket::INET;
 use Selenium::Waiter qw/wait_until/;
@@ -18,7 +19,7 @@ CanStartBinary - Role that a Selenium::Remote::Driver can consume to start a bin
         use Moo;
         with 'Selenium::CanStartBinary';
         extends 'Selenium::Remote::Driver';
-        has 'binary_name' => ( is => 'ro', default => 'chromedriver' );
+        has 'binary' => ( is => 'ro', default => 'chromedriver' );
         has 'binary_port' => ( is => 'ro', default => 9515 );
         1
     };
@@ -45,7 +46,7 @@ severely lacking, and we're pretty naive when we attempt to locate the
 executables on our own. You may be well served in specifying the paths
 to the webdriver in question yourself, if we can't figure it out.
 
-=attr binary_path
+=attr binary
 
 Optional: specify the path to the executable in question. If you don't
 specify anything, we use L<File::Which/which> and take our best guess
@@ -58,12 +59,6 @@ assume you're running a Remote Webdriver instance.
 
 =cut
 
-has 'binary_path' => (
-    is => 'lazy',
-    default => sub { '' },
-    predicate => 1
-);
-
 has 'binary_mode' => (
     is => 'lazy',
     init_arg => undef,

+ 2 - 2
lib/Selenium/Chrome.pm

@@ -41,9 +41,9 @@ has '+port' => (
     is => 'lazy'
 );
 
-has 'binary_name' => (
+has 'binary' => (
     is => 'lazy',
-    default => sub { 'chromedriver' }
+    default => sub { 'chromedriver' },
 );
 
 has 'binary_port' => (

+ 2 - 2
lib/Selenium/Firefox.pm

@@ -41,9 +41,9 @@ has '+port' => (
     default => sub { 4444 }
 );
 
-has 'binary_name' => (
+has 'binary' => (
     is => 'lazy',
-    default => sub { 'firefox' }
+    default => sub { 'firefox' },
 );
 
 has 'binary_port' => (

+ 2 - 2
lib/Selenium/PhantomJS.pm

@@ -42,9 +42,9 @@ has '+port' => (
     is => 'lazy'
 );
 
-has 'binary_name' => (
+has 'binary' => (
     is => 'lazy',
-    default => sub { 'phantomjs' }
+    default => sub { 'phantomjs' },
 );
 
 has 'binary_port' => (

+ 6 - 8
t/CanStartBinary.t

@@ -35,26 +35,24 @@ MANUAL: {
     package ManualChrome {
         use Moo;
         with 'Selenium::CanStartBinary';
-        has 'binary_name' => ( is => 'ro', default => 'fake' );
+        has 'binary' => ( is => 'ro' , default => '' );
         has 'binary_port' => ( is => 'ro', default => 12345 );
         1
     };
 
-    ok( exception { ManualChrome->new( binary_path => '/not/executable') },
+    ok( exception { ManualChrome->new( binary => '/not/executable') },
         'we throw if the user specified binary is not executable');
 
   SKIP: {
         my $phantom_binary = which('phantomjs');
-        skip 'PhantomJS needed for manual binary path tests', 3
+        skip 'PhantomJS needed for manual binary path tests', 2
           unless $phantom_binary;
 
         my $manual_phantom = Selenium::PhantomJS->new(
-            binary_path => $phantom_binary
+            binary => $phantom_binary
         );
-        ok( $manual_phantom->browser_name eq 'phantomjs', 'convenience phantom is okay' );
-        isnt( $manual_phantom->port, 4444, 'phantom can start up its own binary');
-
-        ok( Selenium::CanStartBinary::probe_port( $manual_phantom->port ), 'the chrome binary is listening on its port');
+        isnt( $manual_phantom->port, 4444, 'manual phantom can start up user specified binary');
+        ok( Selenium::CanStartBinary::probe_port( $manual_phantom->port ), 'the manual chrome binary is listening on its port');
     }
 }