File tree 1 file changed +14
-16
lines changed 1 file changed +14
-16
lines changed Original file line number Diff line number Diff line change 1
1
# encoding: UTF-8
2
2
require 'spec_helper'
3
- require 'stringio'
4
3
5
4
RSpec . describe Mysql2 ::Client do
6
5
context "using defaults file" do
@@ -206,22 +205,21 @@ def run_gc
206
205
207
206
if RUBY_PLATFORM =~ /mingw|mswin/
208
207
it "cannot be disabled" do
209
- stderr , $stderr = $stderr, StringIO . new
210
-
211
- begin
212
- Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :automatic_close => false ) )
213
- expect ( $stderr. string ) . to include ( 'always closed by garbage collector' )
214
- $stderr. reopen
215
-
216
- client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] )
208
+ expect do
209
+ client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :automatic_close => false ) )
210
+ expect ( client . automatic_close? ) . to be ( true )
211
+ end . to output ( /always closed by garbage collector/ ) . to_stderr
212
+
213
+ expect do
214
+ client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :automatic_close => true ) )
215
+ expect ( client . automatic_close? ) . to be ( true )
216
+ end . to_not output ( /always closed by garbage collector/ ) . to_stderr
217
+
218
+ expect do
219
+ client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :automatic_close => true ) )
217
220
client . automatic_close = false
218
- expect ( $stderr. string ) . to include ( 'always closed by garbage collector' )
219
- $stderr. reopen
220
-
221
- expect { client . automatic_close = true } . to_not change { $stderr. string }
222
- ensure
223
- $stderr = stderr
224
- end
221
+ expect ( client . automatic_close? ) . to be ( true )
222
+ end . to output ( /always closed by garbage collector/ ) . to_stderr
225
223
end
226
224
else
227
225
it "can be configured" do
You can’t perform that action at this time.
0 commit comments