Skip to content

Commit 6087968

Browse files
committed
some more spec cleanup
1 parent 0fc4e0e commit 6087968

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

spec/mysql2/client_spec.rb

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,16 @@ def connect *args
109109

110110
context "#warning_count" do
111111
context "when no warnings" do
112-
before(:each) do
113-
@client.query('select 1')
114-
end
115112
it "should 0" do
113+
@client.query('select 1')
116114
@client.warning_count.should == 0
117115
end
118116
end
119117
context "when has a warnings" do
120-
before(:each) do
118+
it "should > 0" do
121119
# "the statement produces extra information that can be viewed by issuing a SHOW WARNINGS"
122120
# http://dev.mysql.com/doc/refman/5.0/en/explain-extended.html
123121
@client.query("explain extended select 1")
124-
end
125-
it "should > 0" do
126122
@client.warning_count.should > 0
127123
end
128124
end
@@ -134,32 +130,25 @@ def connect *args
134130

135131
context "#query_info" do
136132
context "when no info present" do
137-
before(:each) do
138-
@client.query('select 1')
139-
end
140133
it "should 0" do
134+
@client.query('select 1')
141135
@client.query_info.should be_empty
142136
@client.query_info_string.should be_nil
143137
end
144138
end
145139
context "when has some info" do
146-
before(:each) do
140+
it "should retrieve it" do
147141
@client.query "USE test"
148142
@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
154143

155-
before(:each) do
156144
# http://dev.mysql.com/doc/refman/5.0/en/mysql-info.html says
157145
# # 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).
158146
@client.query("INSERT INTO infoTest (blah) VALUES (1234),(4535)")
159-
end
160-
it "should retrieve it" do
147+
161148
@client.query_info.should eql({:records => 2, :duplicates => 0, :warnings => 0})
162149
@client.query_info_string.should eq('Records: 2 Duplicates: 0 Warnings: 0')
150+
151+
@client.query "DROP TABLE infoTest"
163152
end
164153
end
165154
end
@@ -184,7 +173,7 @@ def connect *args
184173

185174
context "#query" do
186175
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
188177

189178
expect {
190179
@client.query("SELECT 1 UNION SELECT 2", :stream => true, :cache_rows => false)

spec/mysql2/result_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
result = @client.query('SELECT 1')
1111

1212
result.count.should eql(1)
13-
result.each { |r| }
13+
result.each.to_a
1414
result.count.should eql(1)
1515
end
1616

@@ -31,7 +31,7 @@
3131
@client.query "USE test"
3232
result = @client.query("SELECT * FROM mysql2_test WHERE null_test IS NOT NULL", :stream => true, :cache_rows => false)
3333
result.count.should eql(0)
34-
result.each {|r| }
34+
result.each.to_a
3535
result.count.should eql(0)
3636
end
3737

@@ -113,8 +113,8 @@
113113
result = @client.query "SELECT 1 UNION SELECT 2", :stream => true, :cache_rows => false
114114

115115
expect {
116-
result.each {}
117-
result.each {}
116+
result.each.to_a
117+
result.each.to_a
118118
}.to raise_exception(Mysql2::Error)
119119
end
120120
end

0 commit comments

Comments
 (0)