23

我正在尝试运行users_test.rb刚刚包含的文件

test "the truth" do
     assert true
   end

我确实有一个喜欢表,但我仍然收到此错误。为什么这样?

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
➜  channelappnew  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

谢谢!

4

5 回答 5

54

测试前做rake db:test:prepare

于 2012-05-09T17:52:03.057 回答
5

你跑了rake db:migrate吗?检查数据库表是否存在。如果您正在使用 sqlite,则调用sqlite3 db/development.sqlite3然后发出命令.schema 您可以手动删除数据库db/test.sqlite3,然后使用rake db:setup.

于 2011-10-01T02:40:10.560 回答
2

有时它是由于活动记录宝石的多个版本引起的。请卸载除您的应用程序正在使用的所有 gem。我遇到了同样的问题,并且按照我所说的做了同样的事情。有效。

于 2012-11-19T07:39:12.733 回答
2

你检查过你的固定装置吗?我碰巧修改了迁移但夹具保持不变,因此导致错误。

于 2011-10-01T02:26:55.353 回答
0

我刚遇到同样的问题,在 db/schema.rb 中找到了解决方案:

# Could not dump table "xxx" because of following StandardError
#   Unknown type 'bool' for column 'yyy'

也许这有帮助!

“bool”在除此 schema.rb 之外的任何地方都有效,但迁移在开发模式下正确执行。

于 2012-02-14T08:39:23.443 回答