Created
April 17, 2012 22:56
-
-
Save awesome/2409675 to your computer and use it in GitHub Desktop.
factory girl build vs create
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
#http://archived.rpheath.com/posts/411-how-to-use-factory-girl-with-rspec | |
describe Whatever do | |
before(:each) do | |
@user = Factory.build(:user) # returns an unsaved object | |
@user = Factory.create(:user) # returns a saved object | |
@user = Factory(:user) # shortcut for Factory.create() | |
end | |
it "should be a dumb test to show usage" do | |
@user.name.should == "Ryan Heath" | |
@user.email.should == "[email protected]" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This StackOverflow Q/A does a great job of answering this question as well