2

I'm writing tests with minitest and trying to use miniskirt to handle factories in my rails app. I'm having trouble creating an assocation between my user model and my other models. Since miniskirt does not have Factory#association like factory girl how do you create the association? I'm trying this:

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

But the following test keeps failing as Validation failed: User can't be blank:

require "test_helper"

describe Song do
  it "has a valid factory" do
    Factory.create :song
  end
end
sehe
  • 374,641
  • 47
  • 450
  • 633
Lee McAlilly
  • 9,084
  • 12
  • 60
  • 94
  • I had a similar problem and in my case it was a mass assignment issue i.e. attr_accessible and attr_protected. – codehugger Sep 30 '12 at 00:20

0 Answers0