sqlite3 - Creating test objects in RSpec with FactoryGirl fails with Nested Attributes -
i have workout model has many performedexercises, has many peformedsets. can't build object in test , not sure if it's sqlite3, or else (it works fine outside of testing environment).
i have following factories:
factorygirl.define factory :workout title 'workout one' performed_exercise end factory :performed_exercise exercise_id '2' performed_set end factory :performed_set set_number '1' end end
my rspec test looks (i've made real simple rule out other issues inside test):
it "is causing me lose hair" wrkt = factorygirl.build(:workout) end
when run test, following error message:
failure/error: wrkt = factorygirl.build(:workout) activerecord::statementinvalid: sqlite3::constraintexception: constraint failed: insert "performed_sets" ("created_at", "notes", "performed_exercise_id", "reps", "set_number", "updated_at", "weight") values (?, ?, ?, ?, ?, ?, ?)
any appreciated!
don't set exercise id. let sqlite handle id's you.
factory :performed_exercise performed_set end
Comments
Post a Comment