【问题标题】:rake test and test_structure.sql耙式测试和 test_structure.sql
【发布时间】:2011-02-16 22:35:59
【问题描述】:

首先,我必须运行“rake RAILS_ENV=test ...”来让测试套件访问我的测试数据库。烦人,但可以忍受。

但是,当我这样做时,我会收到一长串这样的错误:

> rake RAILS_ENV=test -I test test:units
psql:/path/to/project/db/test_structure.sql:33: ERROR:  function "armor" already exists with same argument types
[and many more]

看起来一些数据库定义正在不必要地重新加载。我在 Google 上找不到任何提及,所以我想知道其他人是否看到过这个?

我在我的 environment.rb 中使用了一个 PostgreSQL 数据库:

  config.active_record.schema_format = :sql

并使用带有 rake 0.8.7 的 Rails 2.3.5。

此时我已经修复了它,但忘记了如何!我想我可能已经将 pgcrypt 加载到模板模式中,因此数据库正在创建一个已经加载的“空白”数据库,然后 rails 正在从保存的模式中重新定义函数。从模板数据库中卸载函数可以解决这个问题。

【问题讨论】:

    标签: ruby-on-rails postgresql rake test-suite


    【解决方案1】:

    运行 rake 任务的通常约定如下:

    > RAILS_ENV=test rake test:units
    

    或如下:

    > rake test:units RAILS_ENV=test
    

    您可以尝试以上述方式之一运行吗?希望能解决问题!

    【讨论】:

    • 我确实是这样运行的(“-I test”是对单个测试文件运行“ruby -I test ...”的不必要习惯)。
    猜你喜欢
    • 2011-03-02
    • 1970-01-01
    • 2015-11-19
    • 2013-04-09
    • 2011-09-06
    • 2017-12-21
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多