This config worked fine when I was using sqlite:
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
controller.stub(:should_navigate_user?).and_return(false) rescue ""
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
When I switched to PostgreSQL I began getting errors when tests depended on the id number of entries in the database. I looked at the database during the tests and it was never cleaning the database.
If I switch to the following config:
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.clean
controller.stub(:should_navigate_user?).and_return(false) rescue ""
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
All of my tests pass, but I'm having to call clean before and after my methods tests?
I shouldn't have to clean the database before and after each test - right? I feel like I'm misunderstanding something somewhere. What am I failing to understand.