I also double-checked my database.yml settings for test, tried to
refer to a non existing db and got the right error.
Add to your test, after the create line, this…
…and turn off the line in test_helper.rb that says something about
Then run the test, go to another shell, and look in the database for
The deal is that to preserve test isolation, the fixture system erases
entire database between each test case. That’s why I offered the sleep
to see the record before the next test zilches it.
Then, because erasing and rebuilding the entire database is inefficient,
test runner also has the option to build the database once (AFAIK), and
each test case in a transaction. When the transaction rolls back, the
fixtures reappear in the correct state for the text test.
Because one user (actually one database connection) cannot see the
another connection’s transaction until it commits, and because our
will never commit, you must disable the transaction system to see your
Going forward, put your sample records into test/fixtures/*yml, and then
rake db:fixtures:load to populate your development database for manual