I am trying to run users_test.rb
file which just has
test "the truth" do
assert true
end
I do have a likes table, still I am getting this error. Why so?
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
➜ channelappnew rake db:test:clone
➜ channelappnew rake db:test:clone_structure
➜ channelappnew rake db:migrate
➜ channelappnew rake db:test:load
➜ channelapp开发者_JAVA技巧new rake db:test:prepare
➜ channelappnew rake db:test:purge
➜ channelappnew ruby -Itest test/unit/user_test.rb
Loaded suite test/unit/user_test
Started
E
Error:
test_the_truth(UserTest):
ActiveRecord::StatementInvalid: Could not find table 'likes'
Finished in 0.058371 seconds.
1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
17.13 tests/s, 0.00 assertions/s
Thanks!
before test do rake db:test:prepare
Have you run rake db:migrate
?
Check database if the table exists. If you are working with sqlite, then call sqlite3 db/development.sqlite3
and then issue command .schema
You can manually delete database db/test.sqlite3
and then re-create it with rake db:setup
.
Have you checked your fixtures? It has happened to me that I modified a migration but the fixture staid the same, therefore causing a error.
Sometimes it is caused due to multiple versions of active record gems. Please uninstall all gems except one that your application is using. I faced the same problem and did same what i said. It worked.
I just had the same problem and found the solution in db/schema.rb:
# Could not dump table "xxx" because of following StandardError
# Unknown type 'bool' for column 'yyy'
maybe this helps!
"bool" worked everywhere except for this schema.rb, but the migrations where executed correctly in development mode.
精彩评论