Skip to content

Instantly share code, notes, and snippets.

@enriquez
Forked from jferris/factories.rb
Created October 29, 2010 03:18
Show Gist options
  • Save enriquez/652829 to your computer and use it in GitHub Desktop.
Save enriquez/652829 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