0
ユーザーには多くのプロファイルがあります。テストレール "関連"
親のテストに問題はありません。私はその関連性をテストすることに固執しています。
プロファイルモデルは次のとおりです。
class Profile < ApplicationRecord
belongs_to :user
validates_presence_of :first_name, :last_name
end
そしてprofile_testファイルは次のとおりです。
require 'test_helper'
class ProfileTest < ActiveSupport::TestCase
test "create profile" do
profile = Profile.new({"first_name"=>"test", "last_name"=>"test"})
assert profile.save
end
end
私がテストを実行すると、それは失敗を取得します。
Minitest::Assertion: Expected false to be truthy.
缶だれでもしてくださいCreateがうまくいかない理由を明確にしてください。