From 32606db5e93c4bfbfa69e03a8b743913c7bb478e Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Fri, 12 Feb 2010 18:41:34 -0500 Subject: [PATCH] minor: test fix --- lib/mongo.rb | 1 + lib/mongo/gridfs/grid_io.rb | 6 +----- test/test_grid.rb | 12 ++++-------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/mongo.rb b/lib/mongo.rb index fcc965c..e71ed29 100644 --- a/lib/mongo.rb +++ b/lib/mongo.rb @@ -58,5 +58,6 @@ require 'mongo/connection' require 'mongo/cursor' require 'mongo/db' require 'mongo/exceptions' +require 'mongo/gridfs' require 'mongo/gridfs/grid' require 'mongo/gridfs/grid_io' diff --git a/lib/mongo/gridfs/grid_io.rb b/lib/mongo/gridfs/grid_io.rb index 3aa51cb..b54142e 100644 --- a/lib/mongo/gridfs/grid_io.rb +++ b/lib/mongo/gridfs/grid_io.rb @@ -167,10 +167,6 @@ module Mongo chunk || {} end - def delete_chunks(selector) - @chunks.remove(selector) - end - def last_chunk_number (@file_length / @chunk_size).to_i end @@ -215,7 +211,7 @@ module Mongo @current_chunk = get_chunk(0) @file_position = 0 when 'w' - delete_chunks({'_files_id' => }) + @chunks.remove({'_files_id' => @files_id}) @metadata = opts[:metadata] if opts[:metadata] @chunks.create_index([['files_id', Mongo::ASCENDING], ['n', Mongo::ASCENDING]]) diff --git a/test/test_grid.rb b/test/test_grid.rb index e1dc88a..2e424a2 100644 --- a/test/test_grid.rb +++ b/test/test_grid.rb @@ -1,7 +1,6 @@ require 'test/test_helper' class GridTest < Test::Unit::TestCase - include GridFS def setup @db ||= Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', @@ -17,18 +16,15 @@ class GridTest < Test::Unit::TestCase context "When reading:" do setup do - @data = "CHUNKS" * 50000 - GridStore.open(@db, 'sample', 'w') do |f| - f.puts @data + @data = "CHUNKS" * 50000 + @grid = Grid.new(@db) + @grid.open('sample', 'w') do |f| + f.write @data end @grid = Grid.new(@db) end - should "contain sample data" do - assert_equal @data, GridStore.read(@db, 'sample') - end - should "read sample data" do data = @grid.open('sample', 'r') { |f| f.read } assert_equal data.length, @data.length