File tree Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Original file line number Diff line number Diff line change @@ -96,10 +96,7 @@ def connect *args
96
96
first_conn_id = result . first [ 'CONNECTION_ID()' ]
97
97
98
98
# break the current connection
99
- begin
100
- client . query ( "KILL #{ first_conn_id } " )
101
- rescue Mysql2 ::Error
102
- end
99
+ expect { client . query ( "KILL #{ first_conn_id } " ) } . to raise_error ( Mysql2 ::Error )
103
100
104
101
client . ping # reconnect now
105
102
@@ -404,13 +401,7 @@ def connect *args
404
401
thr = Thread . new { @client . query ( "SELECT 1" , :async => true ) }
405
402
406
403
thr . join
407
- begin
408
- @client . query ( "SELECT 1" )
409
- rescue Mysql2 ::Error => e
410
- message = e . message
411
- end
412
- re = Regexp . escape ( thr . inspect )
413
- message . should match ( Regexp . new ( re ) )
404
+ expect { @client . query ( 'SELECT 1' ) } . to raise_error ( Mysql2 ::Error , Regexp . new ( Regexp . escape ( thr . inspect ) ) )
414
405
end
415
406
416
407
it "should timeout if we wait longer than :read_timeout" do
@@ -461,7 +452,6 @@ def connect *args
461
452
} . should raise_error ( Mysql2 ::Error )
462
453
end
463
454
464
-
465
455
it 'should be impervious to connection-corrupting timeouts ' do
466
456
pending ( '`Thread.handle_interrupt` is not defined' ) unless Thread . respond_to? ( :handle_interrupt )
467
457
# attempt to break the connection
Original file line number Diff line number Diff line change 338
338
end
339
339
340
340
it "should raise an error given an invalid DATETIME" do
341
- begin
342
- @client . query ( "SELECT CAST('1972-00-27 00:00:00' AS DATETIME) as bad_datetime" ) . each
343
- rescue Mysql2 ::Error => e
344
- error = e
345
- end
346
-
347
- error . message . should eql ( "Invalid date in field 'bad_datetime': 1972-00-27 00:00:00" )
341
+ expect { @client . query ( "SELECT CAST('1972-00-27 00:00:00' AS DATETIME) as bad_datetime" ) . each } . to \
342
+ raise_error ( Mysql2 ::Error , "Invalid date in field 'bad_datetime': 1972-00-27 00:00:00" )
348
343
end
349
344
350
345
if defined? Encoding
You can’t perform that action at this time.
0 commit comments