test/test_io.rb in swift-0.4.1 vs test/test_io.rb in swift-0.4.2
- old
+ new
@@ -12,15 +12,19 @@
end
it 'stores and retrieves an image' do
Swift.db do |db|
io = File.open(File.dirname(__FILE__) + '/house-explode.jpg')
- db.prepare("insert into users (name, image) values(?, ?)").execute('test', io)
- value = db.prepare("select image from users limit 1").execute.first[:image]
+ db.prepare('insert into users (name, image) values(?, ?)').execute('test', io)
+ blob = db.prepare('select image from users limit 1').execute.first[:image]
+
io.rewind
- assert_equal Encoding::ASCII_8BIT, value.encoding
- assert_equal io.read.force_encoding("ASCII-8BIT"), value
+ assert_kind_of StringIO, blob
+
+ data = blob.read
+ assert_equal Encoding::ASCII_8BIT, data.encoding
+ assert_equal io.read.force_encoding('ASCII-8BIT'), data
end
end
end
end
end