2

私は minitest でテストを書いており、miniskirt を使用して Rails アプリのファクトリを処理しようとしています。ユーザー モデルと他のモデルとの関連付けを作成するのに問題があります。ミニスカに工場少女のようなものがないのでFactory#association、どうやって交際をつくっていますか?私はこれを試しています:

Factory.define :user do |f|
  f.email "joey@ramones.com"
  f.password f.password_confirmation("rockaway")
end

Factory.define :song do |f|
  f.title "I Wanna Be Sedated"
  f.artist "Ramones"
  f.credits "Recorded on February 12-19, 1976 at Plaza Sound, Radio City Music Hall in New York City for Sire Records. All Songs by The Ramones."
  f.artwork "name-of-the-file.jpg"
  f.user { Factory :user }
end

ただし、次のテストは次のように失敗し続けますValidation failed: User can't be blank

require "test_helper"

describe Song do
  it "has a valid factory" do
    Factory.create :song
  end
end
4

0 に答える 0