<困っていること>
railsチュートリアル8章の後半で今まで通ってきたテストの全てがエラーになりました。
デバックしようとしましたが
エラーが多すぎてどこから手をつけたらいいかわからず
とても困ってしまった為質問させていただきます。
<エラー>
E
Error:
SessionsControllerTest#test_should_get_new:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
SessionsControllerTest#test_should_get_new:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/controllers/sessions_controller_test.rb:4
E
Error:
StaticPagesControllerTest#test_should_get_help:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
StaticPagesControllerTest#test_should_get_help:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/controllers/static_pages_controller_test.rb:11
E
Error:
StaticPagesControllerTest#test_should_get_home:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
StaticPagesControllerTest#test_should_get_home:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/controllers/static_pages_controller_test.rb:5
E
Error:
StaticPagesControllerTest#test_should_get_about:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
StaticPagesControllerTest#test_should_get_about:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/controllers/static_pages_controller_test.rb:17
E
Error:
StaticPagesControllerTest#test_should_get_contact:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
StaticPagesControllerTest#test_should_get_contact:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/controllers/static_pages_controller_test.rb:23
E
Error:
UsersLoginTest#test_login_with_invalid_information:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
UsersLoginTest#test_login_with_invalid_information:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/integration/users_login_test.rb:9
E
Error:
UsersLoginTest#test_login_with_valid_information:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
UsersLoginTest#test_login_with_valid_information:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/integration/users_login_test.rb:19
E
Error:
UsersSignupTest#test_valid_signup_information:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
UsersSignupTest#test_valid_signup_information:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/integration/users_signup_test.rb:17
E
Error:
UsersSignupTest#test_invalid_signup_information:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
UsersSignupTest#test_invalid_signup_information:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/integration/users_signup_test.rb:5
E
Error:
UsersControllerTest#test_should_get_new:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
UsersControllerTest#test_should_get_new:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/controllers/users_controller_test.rb:5
E
Error:
UserTest#test_password_should_be_present_(nonblank):
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:59
E
Error:
UserTest#test_email_should_not_be_too_long:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:30
E
Error:
UserTest#test_password_should_have_a_minimum_length:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:64
E
Error:
UserTest#test_email_should_be_present:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:20
E
Error:
UserTest#test_name_should_not_be_too_long:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:25
E
Error:
UserTest#test_email_validation_should_accept_valid_addresses:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:35
E
Error:
UserTest#test_name_should_be_present:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:15
E
Error:
UserTest#test_should_be_valid:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:11
E
Error:
UserTest#test_email_validation_should_reject_invalid_addresses:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:44
E
Error:
UserTest#test_email_addresses_should_be_unique:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
rails test test/models/user_test.rb:53
E
Error:
SiteLayoutTest#test_layout_links:
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /home/ubuntu/environment/sample_app/test/fixtures/users.yml, keys: ["name", "email", "password_digest"]
Error:
SiteLayoutTest#test_layout_links:
NoMethodError: undefined method `each' for nil:NilClass
rails test test/integration/site_layout_test.rb:5
<環境>
cloud9で開発
<実施したこと>
・全てのテストの内容を以下のgit内のと一致していることを確認しました。
https://github.com/yasslab/sample_apps/tree/master/6_0_0/ch08
・railsチュートリアル8章で書いたコードを一度コメントアウトしても同じエラーが出ました。
エラーがたくさん出てしまってとても驚いてしまい内容に不足点があるかもしれません…
<追記>
user.rb⇩
class User < ApplicationRecord
before_save { self.email = email.downcase }
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+-.]+@[a-z\d-.]+.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX },
uniqueness: true
has_secure_password
validates :password, presence: true, length: { minimum: 6 }
#渡された文字列のハッシュ値を返す
def User.digest(string)
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
BCrypt::Engine.cost
BCrypt::Password.create(string, cost: cost)
end
end
yml
1 michael: 2 name: Michael Example 3 email: michael@example.com 4 password_digest: <%= User.digest('password') %>
回答1件
あなたの回答
tips
プレビュー