#50 - advanced tests (test 13)
authorFedor Yudanov <fedwiz@academ.org>
Thu, 4 Apr 2013 13:31:46 +0000 (20:31 +0700)
committerFedor Yudanov <fedwiz@academ.org>
Thu, 4 Apr 2013 13:31:46 +0000 (20:31 +0700)
rbejdb/src/rbejdb.c
rbejdb/test/t2.rb

index d70ab72..b70c15d 100644 (file)
@@ -116,7 +116,12 @@ void EJDB_close(VALUE self) {
     ejdbclose(ejdb);
 }
 
-void EJDB_drop_collection(VALUE self, VALUE collName, VALUE prune) {
+void EJDB_drop_collection(int argc, VALUE* argv, VALUE self) {
+    VALUE collName;
+    VALUE prune;
+
+    rb_scan_args(argc, argv, "11", &collName, &prune);
+
     SafeStringValue(collName);
 
     EJDB* ejdb = getEJDB(self);
@@ -588,7 +593,7 @@ Init_rbejdb() {
     rb_define_method(ejdbClass, "update", RUBY_METHOD_FUNC(EJDB_update), -1);
     rb_define_method(ejdbClass, "remove", RUBY_METHOD_FUNC(EJDB_remove), 2);
 
-    rb_define_method(ejdbClass, "drop_collection", RUBY_METHOD_FUNC(EJDB_drop_collection), 2);
+    rb_define_method(ejdbClass, "drop_collection", RUBY_METHOD_FUNC(EJDB_drop_collection), -1);
     rb_define_method(ejdbClass, "ensure_collection", RUBY_METHOD_FUNC(EJDB_ensure_collection), -1);
 
     rb_define_method(ejdbClass, "drop_indexes", RUBY_METHOD_FUNC(EJDB_drop_indexes), 2);
index 0aa4a36..42cefd7 100644 (file)
@@ -338,5 +338,20 @@ class EJDBTestUnit < Test::Unit::TestCase
     assert_not_nil $jb
     assert $jb.is_open?
     $jb.sync
+    puts "test_ejdbc_sync has passed successfull"
   end
+
+  def test_ejdbd_remove_colls
+    assert_not_nil $jb
+    assert $jb.is_open?
+
+    $jb.drop_collection("birds")
+
+    results = $jb.find("birds", {})
+    assert_equal(0, results.count)
+    assert_nil results.find { true }
+
+    puts "test_ejdbd_remove_colls has passed successfull"
+  end
+
 end