Created
November 23, 2011 19:57
-
-
Save goganchic/1389720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Room < ActiveRecord::Base | |
has_many :auctions | |
end | |
class Auction < ActiveRecord::Base | |
belongs_to :room | |
validates :room, :presence => true | |
end | |
FactoryGirl.define do | |
factory :room do | |
group | |
factory :room_with_auctions do | |
after_build do |r| | |
r.auctions = [Factory.build(:auction, :room => nil)] | |
end | |
end | |
end | |
end | |
FactoryGirl.define do | |
factory :auction do | |
room | |
end | |
end | |
Failure/Error: let(:room) { Factory(:room_with_auctions) } | |
ActiveRecord::RecordInvalid: | |
Validation failed: Auctions is invalid | |
ree-1.8.7-2011.03 :005 > r = Factory(:room, :auctions => [a]) | |
ActiveRecord::RecordInvalid: Validation failed: Auctions is invalid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment