RSpec leaves record in test database
Posted
by
DMiller
on Stack Overflow
See other posts from Stack Overflow
or by DMiller
Published on 2013-10-06T14:21:42Z
Indexed on
2014/05/28
3:27 UTC
Read the original article
Hit count: 131
Whenever I run a user test, RSpec leaves the Fabricated user in the test database after the test has completed, which is messing up my other tests. I will do a rake db:test:prepare
, but when I run my tests again, the record is recreated in my database. I have no idea why this is happening. It only happens with user objects.
In my spec_helper file I even have:
config.use_transactional_fixtures = true
Here is an example test that creates a record:
it "creates a password reset token for the user" do
alice = Fabricate(:user)
post :create, email: alice.email
expect(assigns(alice.password_reset_token)).to_not eq(nil)
end
Fabricator:
Fabricator(:user) do
email { Faker::Internet.email }
password 'password'
name { Faker::Name.name }
end
Could this have anything to do with my users model?
© Stack Overflow or respective owner