Question

I am using Postgres 9.1, Rails 3.1.3 and Ruby 1.9.3.

I tried some things out in rails console --sandbox and then I ventured to rails console. On entering Employee.create!(a whole lot of data), I got some errors, most of them to do with not null constraints.

I quickly left the console and using pgadmin3 checked to see if I had changed the database but there was no data so I felt confident that my tests would still pass. Unfortunately, my rspec test now fails and I am not sure where the conflicting data is.

Hopefully someone reading this has an idea or suggestion of how I can undo the entry I entered in my console session, which unfortunately was not the --sandbox session.

I did manage to kill the phantom server which I found through lsof | grep 3000.

Thanks for any help, suggestions or pointers you can spare.

Was it helpful?

Solution

When you play in the console, you're in the development environment, I don't think there is a way that it conflicts with your tests which are run in the test env. Plus, the tests should not rely on any existant data, since the test database is erased each time you run your tests.

Try to run rake db:test:prepare and run your tests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top