File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -1112,7 +1112,7 @@ static VALUE set_automatic_close(VALUE self, VALUE value) {
1112
1112
#ifndef _WIN32
1113
1113
wrapper -> automatic_close = 0 ;
1114
1114
#else
1115
- rb_raise ( cMysql2Error , "Connections are always closed by garbage collector on Windows" );
1115
+ rb_warn ( "Connections are always closed by garbage collector on Windows" );
1116
1116
#endif
1117
1117
}
1118
1118
return value ;
Original file line number Diff line number Diff line change 1
1
# encoding: UTF-8
2
2
require 'spec_helper'
3
+ require 'stringio'
3
4
4
5
RSpec . describe Mysql2 ::Client do
5
6
context "using defaults file" do
@@ -197,14 +198,22 @@ def run_gc
197
198
198
199
if RUBY_PLATFORM =~ /mingw|mswin/
199
200
it "cannot be disabled" do
200
- expect {
201
+ stderr , $stderr = $stderr, StringIO . new
202
+
203
+ begin
201
204
Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :automatic_close => false ) )
202
- } . to raise_error ( Mysql2 ::Error )
205
+ expect ( $stderr. string ) . to include ( 'always closed by garbage collector' )
206
+ $stderr. reopen
203
207
204
- client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] )
208
+ client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] )
209
+ client . automatic_close = false
210
+ expect ( $stderr. string ) . to include ( 'always closed by garbage collector' )
211
+ $stderr. reopen
205
212
206
- expect { client . automatic_close = false } . to raise_error ( Mysql2 ::Error )
207
- expect { client . automatic_close = true } . to_not raise_error
213
+ expect { client . automatic_close = true } . to_not change { $stderr. string }
214
+ ensure
215
+ $stderr = stderr
216
+ end
208
217
end
209
218
else
210
219
it "can be configured" do
You can’t perform that action at this time.
0 commit comments