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?
Things i think off:
rake spec
to run your testsuite: that builds up the database from scratch (to make sure nothing is sticking)before (:all)
? Because whatever you create inside a before :all
should be deleted again in a after :all
or it keeps on existing.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With