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