소스 검색

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 11 년 전
부모
커밋
384b7b81ac
1개의 변경된 파일25개의 추가작업 그리고 0개의 파일을 삭제
  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 {