Explorar el Código

Fix #152: Ensure consistent error messaging

This came out of an email discussion where the error message for trying
to start Chromedriver without having previously configured your selenium
server was unhelpful. As per #152, we want to be sure not to muck up the
current error message, as users may rightly be depending on it. So,
we lock it down with a test.
Daniel Gempesaw hace 11 años
padre
commit
384b7b81ac
Se han modificado 1 ficheros con 25 adiciones y 0 borrados
  1. 25 0
      t/error.t

+ 25 - 0
t/error.t

@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Test::Exception;
+use Test::LWP::UserAgent;
 use IO::Socket::INET;
 
 
@@ -14,6 +15,30 @@ BEGIN: {
     }
 }
 
+UNAVAILABLE_BROWSER: {
+    my $tua = Test::LWP::UserAgent->new;
+
+    $tua->map_response(qr{status}, HTTP::Response->new(200, 'OK'));
+    $tua->map_response(qr{session}, HTTP::Response->new(
+        500,
+        'Internal Server Error',
+        ['Content-Type' => 'application/json'],
+        '{"status":13,"sessionId":null,"value":{"message":"The path to..."} }'
+    ));
+
+    throws_ok(
+        sub {
+            Selenium::Remote::Driver->new_from_caps(
+                ua => $tua,
+                desired_capabilities => {
+                    browserName => 'chrome'
+                }
+            );
+        }, qr/Could not create new session.*path to/,
+        'Errors in browser configuration are passed to user'
+    );
+}
+
 LOCAL: {
     throws_ok(
         sub {