【问题标题】:Error: SessionsControllerTest#test_should_get_new: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError错误:SessionsControllerTest#test_should_get_new: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError
【发布时间】:2015-10-14 06:04:52
【问题描述】:

我正在使用 ruby​​ -v 2.2.3 & rails -v 4.2.4 。我在注册后尝试使用 $ bundle exec rake test 命令进行测试,但是终端抛出了很多错误。错误是 1) 错误: SessionsControllerTest#test_should_get_new: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: SessionsControllerTest#test_should_get_new: NoMethodError: nil:NilClass 的未定义方法“每个”

2) 错误: 用户控制器测试#test_should_get_new: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: 用户控制器测试#test_should_get_new: NoMethodError: nil:NilClass 的未定义方法“每个”

3) 错误: ZapsControllerTest#test_should_get_about: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: ZapsControllerTest#test_should_get_about: NoMethodError: nil:NilClass 的未定义方法“每个”

4) 错误: ZapsControllerTest#test_should_get_home: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: ZapsControllerTest#test_should_get_home: NoMethodError: nil:NilClass 的未定义方法“每个”

5) 错误: ZapsControllerTest#test_should_get_contact: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: ZapsControllerTest#test_should_get_contact: NoMethodError: nil:NilClass 的未定义方法“每个”

6) 错误: ZapsControllerTest#test_should_get_help: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: ZapsControllerTest#test_should_get_help: NoMethodError: nil:NilClass 的未定义方法“每个”

7) 错误: SiteLayoutTest#test_layout_links: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: SiteLayoutTest#test_layout_links: NoMethodError: nil:NilClass 的未定义方法“每个”

8) 错误: UsersSignupTest#test_invalid_signup_information: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: UsersSignupTest#test_invalid_signup_information: NoMethodError: nil:NilClass 的未定义方法“每个”

9) 错误: UserTest#test_password_should_have_a_minimum_length: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

10) 错误: 用户测试#test_name_should_be_present: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

11) 错误: 用户测试#test_email_should_not_be_too_long: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

12) 错误: UserTest#test_email_validation_should_reject_invalid_addresses: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

13) 错误: 用户测试#test_email_should_be_present: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

14) 错误: UserTest#test_password_should_be_present_(非空白): ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

15) 错误: 用户测试#test_should_be_valid: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

16) 错误: 用户测试#test_name_should_not_be_too_long: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

17) 错误: UserTest#test_email_addresses_should_be_unique: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

18) 错误: UserTest#test_email_validation_should_accept_valid_addresses: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

19) 错误: 用户登录测试#test_login_with_invalid_information: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: 用户登录测试#test_login_with_invalid_information: NoMethodError: nil:NilClass 的未定义方法“每个”

20) 错误: 用户登录测试#test_login_with_valid_information: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

错误: 用户登录测试#test_login_with_valid_information: NoMethodError: nil:NilClass 的未定义方法“每个”

20 次运行,0 次断言,0 次失败,20 次错误,0 次跳过

users.yml 文件中的代码是

http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 阅读有关灯具的信息

潘卡吉: 姓名:潘卡杰 电子邮件:pankajbarhate13@gmail.com password_digest:

请给我解决问题的方法。

【问题讨论】:

  • Stackoverflow 是就具体问题提出具体问题的地方 - 您不能只是将整个项目都放在一个问题中,然后指望有人为您完成工作。

标签: ruby-on-rails


【解决方案1】:

这个问题太令人困惑了。它的接缝表明您的某些对象未初始化。检查您正在调用的所有对象 .each。

【讨论】:

    【解决方案2】:

    我看到了这个确切的错误。在挖掘之后,我发现了以下 Stack Overflow 问题:SO Question

    我的一个固定装置有问题。我开始向one: 添加属性但停止了,我删除了大括号但从未添加任何 yml 属性。

    这是生成的代码

    one: {}
    

    这是我损坏的 yml

    one:
    

    只需将{} 添加回来,一切正常。您的语法错误可能是其他一些非法 yml 格式的结果,但我希望这可以帮助其他人走上正确的道路。

    【讨论】:

      【解决方案3】:

      如果您在 /test/fixtures 中有 users.yml 文件,则提交那里的所有行

      【讨论】:

      猜你喜欢
      • 2014-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 2023-02-06
      • 2017-03-07
      • 2023-03-22
      • 1970-01-01
      相关资源
      最近更新 更多