这个测试一直失败,我不知道为什么:
test "correctly formatted profile_name2" do
user = User.new(first_name: 'Jim', last_name: 'Johnson', email: 'jim@teamtreehouse.com', password: 'awfawwf', profile_name: "jimmy")
puts user.errors.inspect
assert user.valid?
end
我试图通过该语句找出puts user.errors.inspect
答案,但我得到了一个数组(我认为),它只是列出了数据库输入,而不是准确地列出了失败的原因。
为了澄清:
<ActiveModel::Errors:0x00000103c8ad30 @base=#<User id: nil, first_name: "Jim", last_name: "Johnson", profile_name: "jimmy", email: "jim@teamtreehouse.com", encrypted_password: "$2a$04$LTOb5O.gG0DEITsb/HDOb.fPLP83LaXzKlEerwCDE1og...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, confirmation_token: nil, confirmed_at: nil, confirmation_sent_at: nil, unconfirmed_email: nil, failed_attempts: 0, unlock_token: nil, locked_at: nil, authentication_token: nil, created_at: nil, updated_at: nil>, @messages={}>
在未来的测试中,测试中使用了哪些语句来明确打印出问题所在?