错误:SessionsControllerTest#test_should_get_new:ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

时间:2015-10-14 06:04:52

标签: ruby-on-rails

我使用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:未定义的方法`每个'为零:NilClass

2)错误: 的UsersControllerTest#test_should_get_new: ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

错误: 的UsersControllerTest#test_should_get_new: NoMethodError:未定义的方法`每个'为零:NilClass

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

错误: ZapsControllerTest#test_should_get_about: NoMethodError:未定义的方法`每个'为零:NilClass

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

错误: ZapsControllerTest#test_should_get_home: NoMethodError:未定义的方法`每个'为零:NilClass

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

错误: ZapsControllerTest#test_should_get_contact: NoMethodError:未定义的方法`每个'为零:NilClass

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

错误: ZapsControllerTest#test_should_get_help: NoMethodError:未定义的方法`每个'为零:NilClass

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

错误: SiteLayoutTest#test_layout_links: NoMethodError:未定义的方法`每个'为零:NilClass

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

错误: UsersSignupTest#test_invalid_signup_information: NoMethodError:未定义的方法`每个'为零:NilClass

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

10)错误: UserTest#test_name_should_be_present: ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

11)错误: UserTest#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)错误: UserTest#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)错误: UserTest#test_should_be_valid: ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

16)错误: UserTest#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)错误: UsersLoginTest#test_login_with_invalid_information: ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

错误: UsersLoginTest#test_login_with_invalid_information: NoMethodError:未定义的方法`每个'为零:NilClass

20)错误: UsersLoginTest#test_login_with_valid_information: ActiveRecord :: Fixture :: FormatError:ActiveRecord :: Fixture :: FormatError

错误: UsersLoginTest#test_login_with_valid_information: NoMethodError:未定义的方法`每个'为零:NilClass

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

users.yml文件中的代码是

阅读http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

处的灯具

的Pankaj: 姓名:Pankaj 电子邮件:pankajbarhate13@gmail.com password_digest:<%= User.digest('密码')%>

Plase给我解决问题的方法。

3 个答案:

答案 0 :(得分:0)

这个问题太混乱了。它的接缝,你的一些对象没有初始化。检查您正在呼叫的所有对象.each。

答案 1 :(得分:0)

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

我的灯具问题。我开始向one:添加属性但停止了,我删除了大括号但从未添加任何yml属性。

这是生成的代码

one: {}

这是我破碎的yml

one:

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

答案 2 :(得分:0)

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