Skip to content

Instantly share code, notes, and snippets.

@jferris
Created September 7, 2010 22:11
Show Gist options
  • Save jferris/569231 to your computer and use it in GitHub Desktop.
Save jferris/569231 to your computer and use it in GitHub Desktop.
Factory.define :post do |post_factory|
post_factory.user { Factory.build(:user) }
end
class Post < ActiveRecord::Base
belongs_to :user
validates_presence_of :user_id
end
describe Post, "factory" do
subject { Factory.build(:post) }
it { should be_valid }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment