File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 6
6
@client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :encoding => "utf8" ) )
7
7
end
8
8
9
+ def stmt_count
10
+ @client . query ( "SHOW STATUS LIKE 'Prepared_stmt_count'" ) . first [ 'Value' ] . to_i
11
+ end
12
+
9
13
it "should create a statement" do
10
14
statement = nil
11
- expect { statement = @client . prepare 'SELECT 1' } . to change {
12
- @client . query ( "SHOW STATUS LIKE 'Prepared_stmt_count'" ) . first [ 'Value' ] . to_i
13
- } . by ( 1 )
15
+ expect { statement = @client . prepare 'SELECT 1' } . to change ( &method ( :stmt_count ) ) . by ( 1 )
14
16
expect ( statement ) . to be_an_instance_of ( Mysql2 ::Statement )
15
17
end
16
18
689
691
context 'close' do
690
692
it 'should free server resources' do
691
693
stmt = @client . prepare 'SELECT 1'
692
- expect { stmt . close } . to change {
693
- @client . query ( "SHOW STATUS LIKE 'Prepared_stmt_count'" ) . first [ 'Value' ] . to_i
694
- } . by ( -1 )
694
+ expect { stmt . close } . to change ( &method ( :stmt_count ) ) . by ( -1 )
695
695
end
696
696
697
697
it 'should raise an error on subsequent execution' do
You can’t perform that action at this time.
0 commit comments