سؤال

I want to be able to start my tests pointing at a non-existant couchdb database, so that I can test from a blank canvas. How should I do this?

describe MyCouchModel do
  before :all do
    described_class.drop # This doesn't work!
  end

  it 'should be empty' do
    described-class.all.length.should == 0
  end
end
هل كانت مفيدة؟

المحلول

I found this inside some tests for another library:

MyCouchModel.database.delete!

So in a test you could do:

describe MyCouchModel do
  before :all do
    described_class.database.delete!
    described_class.database.create!
  end
end
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top