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