@@ -109,20 +109,16 @@ def connect *args
109
109
110
110
context "#warning_count" do
111
111
context "when no warnings" do
112
- before ( :each ) do
113
- @client . query ( 'select 1' )
114
- end
115
112
it "should 0" do
113
+ @client . query ( 'select 1' )
116
114
@client . warning_count . should == 0
117
115
end
118
116
end
119
117
context "when has a warnings" do
120
- before ( :each ) do
118
+ it "should > 0" do
121
119
# "the statement produces extra information that can be viewed by issuing a SHOW WARNINGS"
122
120
# http://dev.mysql.com/doc/refman/5.0/en/explain-extended.html
123
121
@client . query ( "explain extended select 1" )
124
- end
125
- it "should > 0" do
126
122
@client . warning_count . should > 0
127
123
end
128
124
end
@@ -134,32 +130,25 @@ def connect *args
134
130
135
131
context "#query_info" do
136
132
context "when no info present" do
137
- before ( :each ) do
138
- @client . query ( 'select 1' )
139
- end
140
133
it "should 0" do
134
+ @client . query ( 'select 1' )
141
135
@client . query_info . should be_empty
142
136
@client . query_info_string . should be_nil
143
137
end
144
138
end
145
139
context "when has some info" do
146
- before ( :each ) do
140
+ it "should retrieve it" do
147
141
@client . query "USE test"
148
142
@client . query "CREATE TABLE IF NOT EXISTS infoTest (`id` int(11) NOT NULL AUTO_INCREMENT, blah INT(11), PRIMARY KEY (`id`))"
149
- end
150
-
151
- after ( :each ) do
152
- @client . query "DROP TABLE infoTest"
153
- end
154
143
155
- before ( :each ) do
156
144
# http://dev.mysql.com/doc/refman/5.0/en/mysql-info.html says
157
145
# # Note that mysql_info() returns a non-NULL value for INSERT ... VALUES only for the multiple-row form of the statement (that is, only if multiple value lists are specified).
158
146
@client . query ( "INSERT INTO infoTest (blah) VALUES (1234),(4535)" )
159
- end
160
- it "should retrieve it" do
147
+
161
148
@client . query_info . should eql ( { :records => 2 , :duplicates => 0 , :warnings => 0 } )
162
149
@client . query_info_string . should eq ( 'Records: 2 Duplicates: 0 Warnings: 0' )
150
+
151
+ @client . query "DROP TABLE infoTest"
163
152
end
164
153
end
165
154
end
@@ -184,7 +173,7 @@ def connect *args
184
173
185
174
context "#query" do
186
175
it "should let you query again if iterating is finished when streaming" do
187
- @client . query ( "SELECT 1 UNION SELECT 2" , :stream => true , :cache_rows => false ) . each { }
176
+ @client . query ( "SELECT 1 UNION SELECT 2" , :stream => true , :cache_rows => false ) . each . to_a
188
177
189
178
expect {
190
179
@client . query ( "SELECT 1 UNION SELECT 2" , :stream => true , :cache_rows => false )
0 commit comments