|
53 | 53 | context "#each" do
|
54 | 54 | it "should yield rows as hash's" do
|
55 | 55 | @result.each do |row|
|
56 |
| - expect(row.class).to eql(Hash) |
| 56 | + expect(row).to be_an_instance_of(Hash) |
57 | 57 | end
|
58 | 58 | end
|
59 | 59 |
|
60 | 60 | it "should yield rows as hash's with symbol keys if :symbolize_keys was set to true" do
|
61 | 61 | @result.each(:symbolize_keys => true) do |row|
|
62 |
| - expect(row.keys.first.class).to eql(Symbol) |
| 62 | + expect(row.keys.first).to be_an_instance_of(Symbol) |
63 | 63 | end
|
64 | 64 | end
|
65 | 65 |
|
66 | 66 | it "should be able to return results as an array" do
|
67 | 67 | @result.each(:as => :array) do |row|
|
68 |
| - expect(row.class).to eql(Array) |
| 68 | + expect(row).to be_an_instance_of(Array) |
69 | 69 | end
|
70 | 70 | end
|
71 | 71 |
|
|
182 | 182 | end
|
183 | 183 |
|
184 | 184 | it "should return nil for a NULL value" do
|
185 |
| - expect(@test_result['null_test'].class).to eql(NilClass) |
| 185 | + expect(@test_result['null_test']).to be_an_instance_of(NilClass) |
186 | 186 | expect(@test_result['null_test']).to eql(nil)
|
187 | 187 | end
|
188 | 188 |
|
189 | 189 | it "should return String for a BIT(64) value" do
|
190 |
| - expect(@test_result['bit_test'].class).to eql(String) |
| 190 | + expect(@test_result['bit_test']).to be_an_instance_of(String) |
191 | 191 | expect(@test_result['bit_test']).to eql("\000\000\000\000\000\000\000\005")
|
192 | 192 | end
|
193 | 193 |
|
194 | 194 | it "should return String for a BIT(1) value" do
|
195 |
| - expect(@test_result['single_bit_test'].class).to eql(String) |
| 195 | + expect(@test_result['single_bit_test']).to be_an_instance_of(String) |
196 | 196 | expect(@test_result['single_bit_test']).to eql("\001")
|
197 | 197 | end
|
198 | 198 |
|
|
259 | 259 | end
|
260 | 260 |
|
261 | 261 | it "should return BigDecimal for a DECIMAL value" do
|
262 |
| - expect(@test_result['decimal_test'].class).to eql(BigDecimal) |
| 262 | + expect(@test_result['decimal_test']).to be_an_instance_of(BigDecimal) |
263 | 263 | expect(@test_result['decimal_test']).to eql(10.3)
|
264 | 264 | end
|
265 | 265 |
|
266 | 266 | it "should return Float for a FLOAT value" do
|
267 |
| - expect(@test_result['float_test'].class).to eql(Float) |
| 267 | + expect(@test_result['float_test']).to be_an_instance_of(Float) |
268 | 268 | expect(@test_result['float_test']).to eql(10.3)
|
269 | 269 | end
|
270 | 270 |
|
271 | 271 | it "should return Float for a DOUBLE value" do
|
272 |
| - expect(@test_result['double_test'].class).to eql(Float) |
| 272 | + expect(@test_result['double_test']).to be_an_instance_of(Float) |
273 | 273 | expect(@test_result['double_test']).to eql(10.3)
|
274 | 274 | end
|
275 | 275 |
|
276 | 276 | it "should return Time for a DATETIME value when within the supported range" do
|
277 |
| - expect(@test_result['date_time_test'].class).to eql(Time) |
| 277 | + expect(@test_result['date_time_test']).to be_an_instance_of(Time) |
278 | 278 | expect(@test_result['date_time_test'].strftime("%Y-%m-%d %H:%M:%S")).to eql('2010-04-04 11:44:00')
|
279 | 279 | end
|
280 | 280 |
|
|
288 | 288 | it "should return DateTime when timestamp is < 1901-12-13 20:45:52" do
|
289 | 289 | # 1901-12-13T20:45:52 is the min for 32bit Ruby 1.8
|
290 | 290 | r = @client.query("SELECT CAST('1901-12-13 20:45:51' AS DATETIME) as test")
|
291 |
| - expect(r.first['test'].class).to eql(klass) |
| 291 | + expect(r.first['test']).to be_an_instance_of(klass) |
292 | 292 | end
|
293 | 293 |
|
294 | 294 | it "should return DateTime when timestamp is > 2038-01-19T03:14:07" do
|
295 | 295 | # 2038-01-19T03:14:07 is the max for 32bit Ruby 1.8
|
296 | 296 | r = @client.query("SELECT CAST('2038-01-19 03:14:08' AS DATETIME) as test")
|
297 |
| - expect(r.first['test'].class).to eql(klass) |
| 297 | + expect(r.first['test']).to be_an_instance_of(klass) |
298 | 298 | end
|
299 | 299 | elsif 1.size == 8 # 64bit
|
300 | 300 | unless RUBY_VERSION =~ /1.8/
|
301 | 301 | it "should return Time when timestamp is < 1901-12-13 20:45:52" do
|
302 | 302 | r = @client.query("SELECT CAST('1901-12-13 20:45:51' AS DATETIME) as test")
|
303 |
| - expect(r.first['test'].class).to eql(Time) |
| 303 | + expect(r.first['test']).to be_an_instance_of(Time) |
304 | 304 | end
|
305 | 305 |
|
306 | 306 | it "should return Time when timestamp is > 2038-01-19T03:14:07" do
|
307 | 307 | r = @client.query("SELECT CAST('2038-01-19 03:14:08' AS DATETIME) as test")
|
308 |
| - expect(r.first['test'].class).to eql(Time) |
| 308 | + expect(r.first['test']).to be_an_instance_of(Time) |
309 | 309 | end
|
310 | 310 | else
|
311 | 311 | it "should return Time when timestamp is > 0138-12-31 11:59:59" do
|
312 | 312 | r = @client.query("SELECT CAST('0139-1-1 00:00:00' AS DATETIME) as test")
|
313 |
| - expect(r.first['test'].class).to eql(Time) |
| 313 | + expect(r.first['test']).to be_an_instance_of(Time) |
314 | 314 | end
|
315 | 315 |
|
316 | 316 | it "should return DateTime when timestamp is < 0139-1-1T00:00:00" do
|
317 | 317 | r = @client.query("SELECT CAST('0138-12-31 11:59:59' AS DATETIME) as test")
|
318 |
| - expect(r.first['test'].class).to eql(DateTime) |
| 318 | + expect(r.first['test']).to be_an_instance_of(DateTime) |
319 | 319 | end
|
320 | 320 |
|
321 | 321 | it "should return Time when timestamp is > 2038-01-19T03:14:07" do
|
322 | 322 | r = @client.query("SELECT CAST('2038-01-19 03:14:08' AS DATETIME) as test")
|
323 |
| - expect(r.first['test'].class).to eql(Time) |
| 323 | + expect(r.first['test']).to be_an_instance_of(Time) |
324 | 324 | end
|
325 | 325 | end
|
326 | 326 | end
|
327 | 327 |
|
328 | 328 | it "should return Time for a TIMESTAMP value when within the supported range" do
|
329 |
| - expect(@test_result['timestamp_test'].class).to eql(Time) |
| 329 | + expect(@test_result['timestamp_test']).to be_an_instance_of(Time) |
330 | 330 | expect(@test_result['timestamp_test'].strftime("%Y-%m-%d %H:%M:%S")).to eql('2010-04-04 11:44:00')
|
331 | 331 | end
|
332 | 332 |
|
333 | 333 | it "should return Time for a TIME value" do
|
334 |
| - expect(@test_result['time_test'].class).to eql(Time) |
| 334 | + expect(@test_result['time_test']).to be_an_instance_of(Time) |
335 | 335 | expect(@test_result['time_test'].strftime("%Y-%m-%d %H:%M:%S")).to eql('2000-01-01 11:44:00')
|
336 | 336 | end
|
337 | 337 |
|
338 | 338 | it "should return Date for a DATE value" do
|
339 |
| - expect(@test_result['date_test'].class).to eql(Date) |
| 339 | + expect(@test_result['date_test']).to be_an_instance_of(Date) |
340 | 340 | expect(@test_result['date_test'].strftime("%Y-%m-%d")).to eql('2010-04-04')
|
341 | 341 | end
|
342 | 342 |
|
343 | 343 | it "should return String for an ENUM value" do
|
344 |
| - expect(@test_result['enum_test'].class).to eql(String) |
| 344 | + expect(@test_result['enum_test']).to be_an_instance_of(String) |
345 | 345 | expect(@test_result['enum_test']).to eql('val1')
|
346 | 346 | end
|
347 | 347 |
|
|
379 | 379 | end
|
380 | 380 |
|
381 | 381 | it "should return String for a SET value" do
|
382 |
| - expect(@test_result['set_test'].class).to eql(String) |
| 382 | + expect(@test_result['set_test']).to be_an_instance_of(String) |
383 | 383 | expect(@test_result['set_test']).to eql('val1,val2')
|
384 | 384 | end
|
385 | 385 |
|
|
412 | 412 | end
|
413 | 413 |
|
414 | 414 | it "should return String for a BINARY value" do
|
415 |
| - expect(@test_result['binary_test'].class).to eql(String) |
| 415 | + expect(@test_result['binary_test']).to be_an_instance_of(String) |
416 | 416 | expect(@test_result['binary_test']).to eql("test#{"\000"*6}")
|
417 | 417 | end
|
418 | 418 |
|
|
453 | 453 | 'long_text_test' => 'LONGTEXT'
|
454 | 454 | }.each do |field, type|
|
455 | 455 | it "should return a String for #{type}" do
|
456 |
| - expect(@test_result[field].class).to eql(String) |
| 456 | + expect(@test_result[field]).to be_an_instance_of(String) |
457 | 457 | expect(@test_result[field]).to eql("test")
|
458 | 458 | end
|
459 | 459 |
|
|
0 commit comments