Similar to the problem described here: http://rpheath.com/posts/411-how-to-use-factory-girl-with-rspec
in Short (shorten'd code):
spec_helper:
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
factories.rb:
Factory.define :state do
f.name "NY"
end
in my spec
before(:each) do
@static_model = Factory(:state) # with validate uniqueness of state name
end
error:
duplicate entry name "NY" etc.
Question: Shouldn't rspec clear database before each spec example and hence not throwing duplicate entry errors?
before(:all)
blocks that insert DB records have a correspondingafter(:all)
block to destroy them! – Skell