Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rake测试错误-ActiveRecord::Fixture::FormatError:“活动记录”;RubyonRails教程“;迈克尔·哈特尔_Ruby On Rails_Ruby_Activerecord - Fatal编程技术网

Ruby on rails Rake测试错误-ActiveRecord::Fixture::FormatError:“活动记录”;RubyonRails教程“;迈克尔·哈特尔

Ruby on rails Rake测试错误-ActiveRecord::Fixture::FormatError:“活动记录”;RubyonRails教程“;迈克尔·哈特尔,ruby-on-rails,ruby,activerecord,Ruby On Rails,Ruby,Activerecord,我遵循MICHAEL HARTL的《Ruby on Rails教程》一书,在第8节,我实现了几个测试。现在,当您启动bundle exec-rake测试时,会出现26个错误,我无法理解什么是不好的 ERROR["test_invalid_signup_information", UsersSignupTest, 2015-05-22 11:12:19 +0200] test_invalid_signup_information#UsersSignupTest (1432285939.41s) A

我遵循MICHAEL HARTL的《Ruby on Rails教程》一书,在第8节,我实现了几个测试。现在,当您启动bundle exec-rake测试时,会出现26个错误,我无法理解什么是不好的

ERROR["test_invalid_signup_information", UsersSignupTest, 2015-05-22 11:12:19 +0200]
test_invalid_signup_information#UsersSignupTest (1432285939.41s)
ActiveRecord::Fixture::FormatError:           ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_valid_signup_information", UsersSignupTest, 2015-05-22 11:12:19 +0200]
test_valid_signup_information#UsersSignupTest (1432285939.42s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_password_should_have_a_minimum_length", UserTest, 2015-05-22 11:12:19 +0200]
test_password_should_have_a_minimum_length#UserTest (1432285939.43s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_email_addresses_should_be_saved_as_lower-case", UserTest, 2015-05-22 11:12:19 +0200]
test_email_addresses_should_be_saved_as_lower-case#UserTest (1432285939.43s)
ActiveRecord::Fixture::FormatError:           ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_email_validation_should_accept_valid_addresses", UserTest, 2015-05-22 11:12:19 +0200]
test_email_validation_should_accept_valid_addresses#UserTest (1432285939.43s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_name_should_not_be_too_long", UserTest, 2015-05-22 11:12:19 +0200]
test_name_should_not_be_too_long#UserTest (1432285939.44s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_password_should_be_present", UserTest, 2015-05-22 11:12:19 +0200]
 test_password_should_be_present#UserTest (1432285939.44s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

 ERROR["test_authenticated?_should_return_false_for_a_user_with_nil_digest",  UserTest, 2015-05-22 11:12:19 +0200]
test_authenticated?_should_return_false_for_a_user_with_nil_digest#UserTest (1432285939.45s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_email_addresses_should_be_unique", UserTest, 2015-05-22 11:12:19 +0200]
test_email_addresses_should_be_unique#UserTest (1432285939.45s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_email_should_be_present", UserTest, 2015-05-22 11:12:19 +0200]
test_email_should_be_present#UserTest (1432285939.46s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_email_should_not_be_too_long", UserTest, 2015-05-22 11:12:19 +0200]
test_email_should_not_be_too_long#UserTest (1432285939.46s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_name_should_be_present", UserTest, 2015-05-22 11:12:19 +0200]
test_name_should_be_present#UserTest (1432285939.46s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_should_be_valid", UserTest, 2015-05-22 11:12:19 +0200]
test_should_be_valid#UserTest (1432285939.47s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_login_with_remembering", UsersLoginTest, 2015-05-22 11:12:19 +0200]    
 test_login_with_remembering#UsersLoginTest (1432285939.47s)
ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


 ERROR["test_login_without_remembering", UsersLoginTest, 2015-05-22 11:12:19 +0200]
 test_login_without_remembering#UsersLoginTest (1432285939.48s)
 ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


 ERROR["test_login_with_valid_information_followed_by_logout", UsersLoginTest, 2015-05-22 11:12:19 +0200]
 test_login_with_valid_information_followed_by_logout#UsersLoginTest (1432285939.48s)
 ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


 ERROR["test_should_get_new", UsersControllerTest, 2015-05-22 11:12:19 +0200]
 test_should_get_new#UsersControllerTest (1432285939.49s)
 ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


 ERROR["test_current_user_returns_right_user_when_session_is_nil", SessionsHelperTest, 2015-05-22 11:12:19 +0200]
test_current_user_returns_right_user_when_session_is_nil#SessionsHelperTest (1432285939.50s)
  ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


 ERROR["test_current_user_returns_nil_when_remember_digest_is_wrong", SessionsHelperTest, 2015-05-22 11:12:19 +0200]
   test_current_user_returns_nil_when_remember_digest_is_wrong#SessionsHelperTest (1432285939.50s)
  ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


 ERROR["test_layout_links", SiteLayoutTest, 2015-05-22 11:12:19 +0200]
  test_layout_links#SiteLayoutTest (1432285939.51s)
  ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


 ERROR["test_should_get_new", SessionsControllerTest, 2015-05-22 11:12:19 +0200]
  test_should_get_new#SessionsControllerTest (1432285939.52s)
 ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


 ERROR["test_should_get_contact", StaticPagesControllerTest, 2015-05-22 11:12:19 +0200]
  test_should_get_contact#StaticPagesControllerTest (1432285939.52s)
 ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_should_get_help", StaticPagesControllerTest, 2015-05-22 11:12:19 +0200]
  test_should_get_help#StaticPagesControllerTest (1432285939.53s)
  ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_should_get_home", StaticPagesControllerTest, 2015-05-22 11:12:19 +0200]
  test_should_get_home#StaticPagesControllerTest (1432285939.53s)
 ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_should_get_about", StaticPagesControllerTest, 2015-05-22 11:12:19 +0200]
 test_should_get_about#StaticPagesControllerTest (1432285939.54s)
 ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError


ERROR["test_full_title_helper", ApplicationHelperTest, 2015-05-22 11:12:19 +0200]
 test_full_title_helper#ApplicationHelperTest (1432285939.54s)
 ActiveRecord::Fixture::FormatError:         ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError
以下是测试文件:

Users.yml

michael:
name: Michael Example
email: michael@example.com
password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要: 用户会话控制器测试

require 'test_helper'

class SessionsControllerTest < ActionController::TestCase
   test "should get new" do
     get :new
    assert_response :success
   end
 end
需要“测试助手”
类SessionControllerTest
谢谢大家的帮助


我编辑了User.yml文件,现在只出现以下错误:


FAIL[“当会话为空时,测试当前用户返回右用户”,会话帮助测试,2015-05-22 11:12:20+0200]
test_current_user_返回_right_user_当_session_为_nil#Sessions HelperTest(1432285940.28s)
---期望
+++实际的
@@ -1 +1 @@
-#
+零
test/helpers/sessions\u helper\u test.rb:10:in'block in'
会话助手测试

require 'test_helper'
class SessionsHelperTest < ActionView::TestCase

  def setup
    @user = users(:micheal)
    remember(@user)
   end

  test "current_user returns right user when session is nil" do
    assert_equal @user, current_user
    assert is_logged_in?
  end

  test "current_user returns nil when remember digest is wrong" do
    @user.update_attribute(:remember_digest, User.digest(User.new_token))
    assert_nil current_user
  end
end
需要“测试助手”
类SessionHelperTest
您的装置似乎有一些不好的格式。在测试之前加载装置,如果出现问题,您将得到错误“ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError”。由于每个测试都依赖于固定装置,因此每个测试都会显示此信息

在YAML中,缩进非常重要。在Users.yml文件中,需要添加一点缩进,如下所示:

michael:
  name: Michael Example
  email: michael@example.com
  password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要:
您的装置似乎有一些不好的格式。在测试之前加载装置,如果出现问题,您将得到错误“ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError”。由于每个测试都依赖于固定装置,因此每个测试都会显示此信息

在YAML中,缩进非常重要。在Users.yml文件中,需要添加一点缩进,如下所示:

michael:
  name: Michael Example
  email: michael@example.com
  password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要:
您的装置似乎有一些不好的格式。在测试之前加载装置,如果出现问题,您将得到错误“ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError”。由于每个测试都依赖于固定装置,因此每个测试都会显示此信息

在YAML中,缩进非常重要。在Users.yml文件中,需要添加一点缩进,如下所示:

michael:
  name: Michael Example
  email: michael@example.com
  password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要:
您的装置似乎有一些不好的格式。在测试之前加载装置,如果出现问题,您将得到错误“ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError:ActiveRecord::Fixture::FormatError”。由于每个测试都依赖于固定装置,因此每个测试都会显示此信息

在YAML中,缩进非常重要。在Users.yml文件中,需要添加一点缩进,如下所示:

michael:
  name: Michael Example
  email: michael@example.com
  password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要:
您的夹具文件似乎格式错误

Users.yml

michael:
  name: Michael Example
  email: michael@example.com
  password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要: 尝试识别属性


希望有帮助

您的夹具文件似乎格式错误

Users.yml

michael:
  name: Michael Example
  email: michael@example.com
  password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要: 尝试识别属性


希望有帮助

您的夹具文件似乎格式错误

Users.yml

michael:
  name: Michael Example
  email: michael@example.com
  password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要: 尝试识别属性


希望有帮助

您的夹具文件似乎格式错误

Users.yml

michael:
  name: Michael Example
  email: michael@example.com
  password_digest: <%= User.digest('password') %>
迈克尔: 姓名:Michael Example 电邮:michael@example.com 密码摘要: 尝试识别属性


希望有帮助

好的,现在sono stati的错误减少到三个,很好,我不知道为什么我没有注意到下降,因为我在谷歌上搜索了这个错误,我意识到这是一个格式错误,但我读到它是由后面的空格引起的:,我的是。然而,我在上面添加了新的错误。感谢您的帮助,我想我理解了,我将用户Micheal添加到数据库中,现在只有一个错误,位于上面。@LucaVasapolli看起来您只有一个测试失败。显然,
当前用户
返回nil,但期望它应该等于
@user
。回顾教程,确保您没有遗漏任何代码,以使
当前用户
方法正常工作。我纠正了错误,我调用了两次函数current\u user,非常感谢,现在错误sono stati减少到三个,很好,我不知道为什么我没有注意到下降,因为我在谷歌上搜索了这个错误,我意识到这是一个格式错误,但我读到它是由以下空格引起的:,我的是。然而,我在上面添加了新的错误。感谢您的帮助,我想我理解了,我将用户Micheal添加到数据库中,现在只有一个错误,位于上方。@LucaVasapolli看起来像您