私は多くのPerformedExercisesを持つワークアウトモデルを持っています。これには多くのPeformedSetがあります。テストでオブジェクトを構築することができず、それが SQLite3 なのか、それとも何か他のものなのかわかりません (テスト環境の外では問題なく動作します)。
私は次の工場を持っています:
FactoryGirl.define do
factory :workout do
title 'workout one'
performed_exercise
end
factory :performed_exercise do
exercise_id '2'
performed_set
end
factory :performed_set do
set_number '1'
end
end
私の RSpec テストは次のようになります (テスト内の他の問題を除外するために、非常にシンプルにしました):
it "is causing me to lose hair" do
wrkt = FactoryGirl.build(:workout)
end
テストを実行すると、次のエラー メッセージが表示されます。
Failure/Error: wrkt = FactoryGirl.build(:workout)
ActiveRecord::StatementInvalid:
SQLite3::ConstraintException: constraint failed:
INSERT INTO "performed_sets" ("created_at", "notes", "performed_exercise_id", "reps", "set_number", "updated_at", "weight")
VALUES (?, ?, ?, ?, ?, ?, ?)
どんな助けでも大歓迎です!