Ruby Couchbase & Couchbase Model working with Cucumber/ DatabaseCleaner

May I know if anyone has tried working on Cucumber/DatabaseCleaner and Rails/Couchbase.
I was able to run Cucumber with Rails/Couchbase but I wish to know if anyone knows how to use it with DatabaseCleaner to clean up the DB after running the scenarios. I understand that DatabaseCleaner works with MongoDB and CouchDb but I wonder if any ORM provider could be plugged into Databasecleaner for use.

Hi Oredi,
Currently, there is no Support for the Couchbase Model ORM with Database_Cleaner.
Database_Cleaner allows you to use parameters like :transaction, to roll back tests and :delete to clear out test records.
This isn’t hugely necessary in Couchbase, as we’d recommend in Rails you setup your Couchbase bucket “mybucket_test” for testing, then use the built in ‘Flush’ functionality to clear the bucket out.
I hope this helps.
Robin J.

How do you suggest we go about clearing the database for a testing suite? Right now, using rspec, running a flush after each test increases my test suite time from less than one second to about 1 minute and 20 seconds (this is with 80 or so tests).

How exactly are you running the flush during your test suite?

For reference, I’m using couchbase-model (though I may drop that, I’m not certain if it’s the best way to approach couchbase) with Ruby 1.9.3.

I’m just calling Couchbase.bucket.flush. I’m doing the flush in a config after step in my spec_helper with rspec:

config.after( :each ) do
start =
puts "Flush took #{ - start }"


I changed my approach, and this has restored the speed of my tests. I’ve is monkey patched (with alias_method_chain) Couchbase::Bucket so that all bucket #add and #delete calls are tracked. Any documents that are not deleted by the end of the test are deleted from the bucket specifically. So far, this is worked, and keeps the tests running quickly, but I’m concerned this is not a good long term solution.